
■ module is passed to the TControl base constructor as the TModule
parameter for that constructor; it defaults to 0.
Y u can construct VBX controls either explicitly or implicitly Y u explicitlyo . o
Implicit and explicit
construct an object when you call one of the constructors. Y u implicitlyo
construction
construct an object when you do not call one of the constructors and allow
the control to be instantiated and created by its parent.
Explicit construction involves calling either constructor of a VBX control
object. This is normally done in the parent’ constructor so that the VBXs
control is constructed and ready when the parent window is created. Y uo
can also wait to construct the control until it’ needed; for example, yous
might want to do this if you had room for only one control. In this case,
you could let the user choose a menu choice or press a button. Then,
depending what the user does, you would instantiate an object and display
it in an existing interface element.
The following code demonstrates explicit construction using both of the
TVbxControl constructors in the constructor of a dialog box object:
class TTestDialog : public TDialog, public TVbxEventHandler
{
public:
TTestDialog(TWindow *parent, char *name)
: TDialog(parent, name), TWindow(parent, name)
{
new TVbxControl(this, IDCONTROL1);
new TVbxControl(this, IDCONTROL2,
"SWITCH.VBX", "BiSwitch",
"&Program VBX Control",
16, 70, 200, 50);
}
DECLARE_RESPONSE_TABLE(TTestDialog);
};
Implicit construction takes place when you design your interface element
outside of your application source code, such as in Resource W rkshop.o
Y u can use Resource W rkshop to add VBX controls to dialog boxes ando o
other interface elements. Then when you instantiate the parent object, the
children, such as edit boxes, list boxes, buttons, and VBX controls, are
automatically created along with the parent. The following code
demonstrates how the code for this might look. It’ important to note,s
however that what you don’t see in the following code is a VBX control.,
Instead, the VBX control is included in the dialog resource DIALOG_1.
When DIALOG_1 is loaded and created, the VBX control is automatically
created.
336
OWL P ogrammer’ Guider s