Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In the MFC ,Create modeless dialog ,such as
C++
CDialog *modelessDialog = new CDialog;
modelessDialog->Create(IDC_DIALOG,this)

But in the Composite Control,I want to create modelss dialog,Which not support 'this' params,what can i do?
Posted
Updated 24-Dec-13 14:59pm
v2
Comments
Sergey Alexandrovich Kryukov 24-Dec-13 21:09pm    
The question makes no sense: "this" parameter is the reference to the instance passed to the method. It cannot be supported or not supported (for instance methods); this is a feature of C++ and other OO languages.
—SA
moon_lu 24-Dec-13 21:45pm    
virtual BOOL Create(
LPCTSTR lpszTemplateName,
CWnd* pParentWnd = NULL
);
virtual BOOL Create(
UINT nIDTemplate,
CWnd* pParentWnd = NULL
);
Thank you for you help,There is some mistake,I know 'this' which is a hided pointer,point to the current class.In the Create() ,'this' point to the Parent CWnd.
But
In Composite Control,
class ATL_NO_VTABLE CTaskPane :
public CComObjectRootEx<ccomsinglethreadmodel>,
public IDispatchImpl<itaskpane, &iid_itaskpane,="" &libid_vsatexcelloadlib="">,
public CComCompositeControl<ctaskpane>,
public IPersistStreamInitImpl<ctaskpane>,
public IOleControlImpl<ctaskpane>,
public IOleObjectImpl<ctaskpane>,
public IOleInPlaceActiveObjectImpl<ctaskpane>,
public IViewObjectExImpl<ctaskpane>,
public IOleInPlaceObjectWindowlessImpl<ctaskpane>,
public IPersistStorageImpl<ctaskpane>,
public ISpecifyPropertyPagesImpl<ctaskpane>,
public IQuickActivateImpl<ctaskpane>,
public IDataObjectImpl<ctaskpane>,
public IProvideClassInfo2Impl<&CLSID_TaskPane, NULL,

which not inherit form CWND,So can't create modeless dialog,I don't know what params I can transmit.

Do you know the Composite Control,Which inherit form
class CComCompositeControl : public CComControl< T, CAxDialogImpl< T > >
class ATL_NO_VTABLE CComControl : public CComControlBase, public WinBase.

1 solution

The question makes no sense: "this" parameter is the pointer to the instance passed to the method. It cannot be supported or not supported (for instance methods); this is a feature of C++ and other OO languages.

The code sample also makes no sense, as "this" depends on the context. This is the pointer to the instance passed to some outer method of some class/structure. The method Create expects the second parameter of the type CWnd, as it is shown in this code sample:
http://msdn.microsoft.com/en-us/library/yhth57kd.aspx[^].

You cannot just rip some code fragment out of its context, show it and ask questions about it. Your "this" can be of any type of it may be defined at all (for example, in static functions, in functions which are not members of any class or structure). It has nothing to do with the method Create — the MSDN page referenced above shows what parameters it expects.

Now, to answer your question: what can you do? This is pretty obvious. First of all, you should stop trying to develop MCF applications, UI application or any other advanced stuff; you are not ready yet. You need to start learning C++ and programming, from the very beginning. You can take some manual and proceed in small steps, doing each step with full understanding, trying to do simple exercises, which would better be console-only applications. And also you should change your way of learning. You should stop copying code fragment you don't understand and start writing code from scratch, understanding each line you write. You should not skip topics and stages of your learning. And when you feel pretty confident in basic programming, including all of the OOP, you can get back to UI development or something else.

—SA
 
Share this answer
 
v2
Comments
moon_lu 24-Dec-13 21:44pm    
virtual BOOL Create(
LPCTSTR lpszTemplateName,
CWnd* pParentWnd = NULL
);
virtual BOOL Create(
UINT nIDTemplate,
CWnd* pParentWnd = NULL
);
Thank you for you help,There is some mistake,I know 'this' which is a hided pointer,point to the current class.In the Create() ,'this' point to the Parent CWnd.
But
In Composite Control,
class ATL_NO_VTABLE CTaskPane :
public CComObjectRootEx<ccomsinglethreadmodel>,
public IDispatchImpl<itaskpane, &iid_itaskpane,="" &libid_vsatexcelloadlib="">,
public CComCompositeControl<ctaskpane>,
public IPersistStreamInitImpl<ctaskpane>,
public IOleControlImpl<ctaskpane>,
public IOleObjectImpl<ctaskpane>,
public IOleInPlaceActiveObjectImpl<ctaskpane>,
public IViewObjectExImpl<ctaskpane>,
public IOleInPlaceObjectWindowlessImpl<ctaskpane>,
public IPersistStorageImpl<ctaskpane>,
public ISpecifyPropertyPagesImpl<ctaskpane>,
public IQuickActivateImpl<ctaskpane>,
public IDataObjectImpl<ctaskpane>,
public IProvideClassInfo2Impl<&CLSID_TaskPane, NULL,

which not inherit form CWND,So can't create modeless dialog,I don't know what params I can transmit.

Do you know the Composite Control,Which inherit form
class CComCompositeControl : public CComControl< T, CAxDialogImpl< T > >
class ATL_NO_VTABLE CComControl : public CComControlBase, public WinBase.
Sergey Alexandrovich Kryukov 24-Dec-13 21:53pm    
This is all irrelevant. You need to pass some CWnd or null, which would make your dialog a main application window. You either don't have appropriate instance of CWnd (there are no other windows at the moment, which is fine), or you have it, because some window is already created and is showing; in both cases, ther7e is no a problem.
—СА

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900