ObjectWindows lets you use Visual Basic (VBX) 3.0-compatible controls in your Windows applications as easily as you use standard Windows or ObjectWindows controls.
VBX controls offer a wide range of functionality that is not provided in standard Windows controls. There are numerous public domain and commercial packages of VBX controls that can be used to provide a more polished and useful user interface.
To take advantage of VBX controls, use the two ObjectWindows classes TVbxControl and TVbxEventHandler.
Using VBX Controls
To use VBX controls in your ObjectWindows application, follow this process:
- In your OwlMain function, call the function VBXInit before you call the Run function of your application object. Call the function VBXTerm after you call the Run function of your application object. VBXInit takes the application instance as a parameter. VBXTerm takes no parameters. These functions initialize and close each instance's host environment necessary for using VBX controls. Your OwlMain function might look something like this:
{
int result = TApplication("Wow!").Run();
return result
}
STDAPI_(owl::TDocTemplate **) GetDocTemplateHead(owl STDAPI_(owl::TModule **) GetModulePtr(owl in OwlMain)(int argc, TCHAR *argv[])
Main entry point for an Owl application.
- Derive a class that mixes your base interface class with TVbxEventHandler. Your base interface class is whatever class you want to display the control in. If you are using the control in a dialog box, you need to mix in TDialog. The code would look something like this:
{
public:
:
};
#define DECLARE_RESPONSE_TABLE(cls)
- Build a response table for the parent, including all relevant events from your control. Use the EV_VBXEVENTNAME macro to set up the response for each control event.
- Create the control's parent. You can either construct the control when you create the parent or allow the parent to construct the control itself, depending on how the control is being used.
See Also