how to use control
-
I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?
-
I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?
-
I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?
Hi Parameters for Create function of you control depend on by kind of you control. But generally first parameters its LPCTSTR lpszWindowName is name window of you control for instance for CommandButton its same Caption DWORD dwStyle this style of you control for more see CreateControl() function in MSDN const RECT& rect is rect in what you control appeared CWnd* pParentWnd is parent window (window what will belong you created control) UINT nID is handle of you control simple defined its as any number in "resource.h" file of you object [this number must be vary from already used for resource handling] Sorry for bad eanglish.
-
I have to use a control in doc/view mode, and I want to use the Create function to create a control's instanse, not in the dialog window mode, so I use the "add to projects\components and controls" menu add the control to the project, how can I use the Create function to create the control?
A control is placed on a dialog or form or... inside your doc/view classes you add some classes that contain information ABOUT the control. :confused: confused yet? :confused: for example: on your dialog you have a edit box, in the dialog class you'll need a CEdit member to obtain information about the edit control and it's contents. You don't need to call the create method! If you wan't to dynamically create the controls see the controlyouwant.Create() for details hope this helps...
A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.
-
hello im not sure if im clear on what your asking but have your tried use if(!m_yourcontrol.Create()) { } under the doc or view mode depending on wich you need. Jason Bird
I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );
-
Hi Parameters for Create function of you control depend on by kind of you control. But generally first parameters its LPCTSTR lpszWindowName is name window of you control for instance for CommandButton its same Caption DWORD dwStyle this style of you control for more see CreateControl() function in MSDN const RECT& rect is rect in what you control appeared CWnd* pParentWnd is parent window (window what will belong you created control) UINT nID is handle of you control simple defined its as any number in "resource.h" file of you object [this number must be vary from already used for resource handling] Sorry for bad eanglish.
I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );
-
A control is placed on a dialog or form or... inside your doc/view classes you add some classes that contain information ABOUT the control. :confused: confused yet? :confused: for example: on your dialog you have a edit box, in the dialog class you'll need a CEdit member to obtain information about the edit control and it's contents. You don't need to call the create method! If you wan't to dynamically create the controls see the controlyouwant.Create() for details hope this helps...
A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.
I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );
-
I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );
Classwizard generated classes are derived from CObject and support dynamic creation! If you look inside the class you should see that the default constructor is
protected
! You can't create it with the new operator. You should make it a RUNTIME_CLASS and use CreateObject to create the control. Second you should initialize it with the Create() method. exemple:CRuntimeClass *pClass = RUNTIME_CLASS(CSampleControl); CSampleControl *pControl = (CSampleControl*) pClass->CreateObject(); pControl->Create();
the runtime class contains the RTTI (RunTime Type Information). hope this helps :)A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.
-
I have to add a activex control into the project use doc/view, and the control must hide, so I want to use it as object or class, so I have to dymanic create it, the class wizard generate a class named like CSampleControl, and the interface of the control was generated as class' member function. I use the "new" operator create a control' instanse, when I use create function to create the control, the env throw exception and dump, so how can I do? eg. CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 );
Do you create this control on class method??? If yes where placed define you control and use new operator If for instance you declared you control in some method of you class and after used new operator and create function then after exit from this method you recieve exactly you trouble. I.e bool YouClass::SomeMethod(){ CSampleControl* control; control = new CSampleControl(); control->Create( "", "", WS_CHILD, this, 1000 ); return true;//exit from method and recived exception } Also you may not call AfxEnableControlContainer(); on InitInstaced method of you application