Dec 102017
Microsoft Visual C++ sample application that shows you how to display a vbx control in a dialog box that is a resource of an AFXDLL. | |||
---|---|---|---|
File Name | File Size | Zip Size | Zip Type |
AFXDLLRE.H | 666 | 288 | deflated |
AFXRES.H | 687 | 289 | deflated |
AFXVBX.CPP | 6498 | 1505 | deflated |
AFXVBX.DEF | 881 | 473 | deflated |
AFXVBX.H | 393 | 234 | deflated |
AFXVBX.LIB | 1536 | 107 | deflated |
AFXVBX.MAK | 2202 | 871 | deflated |
AFXVBX.RC | 2141 | 692 | deflated |
AFXVBX.RES | 305 | 240 | deflated |
APP.CPP | 1514 | 502 | deflated |
APP.DEF | 302 | 199 | deflated |
APP.DLG | 462 | 268 | deflated |
APP.H | 1224 | 312 | deflated |
APP.ICO | 766 | 216 | deflated |
APP.MAK | 1880 | 808 | deflated |
APP.RC | 794 | 449 | deflated |
README.TXT | 1611 | 682 | deflated |
RESOURCE.H | 667 | 354 | deflated |
Download File AFXVBX.ZIP Here
Contents of the README.TXT file
This sample application shows you how to display a vbx control in a
dialog box that is a resource of an AFXDLL. The dialog template contains
a list of the controls for the dialog box. One of the items in this list
is the class name for the control. Since VBX controls are not standard
Windows controls they do not have a class name. MFC works around this by
providing a Windows class, VBControl, which it can use to create VBX
controls. The VBControl class is used as the class name in the dialog
template for every VBX control used in the dialog.
When the application that calls the DLL calls the EnableVBX()
function, it registers the VBControl window class with Microsoft
Windows. The VBControl class is registered as a local window class,
not as a global window class. A local window class is available only
to the module in which the class is registered. Because a DLL has its
own module that is different from the calling application, the VBControl
class is not available to the DLL.
Workarounds:
[1] The application can call the Create() member function of the CVBControl
class to create the VBX control. Call Create() in the OnInitDialog()
function (for a modal dialog box) or in the OnCreate() function (for
a modeless dialog box).
[2] Re-register the VBControl class in the DLL so that it can be used from
the DLL. Also, change the resorce instance handle during the
OnInitDialog() function so that resource in the DLL will be used while
the controls are being created.
This second method is demontrated in the sample.
dialog box that is a resource of an AFXDLL. The dialog template contains
a list of the controls for the dialog box. One of the items in this list
is the class name for the control. Since VBX controls are not standard
Windows controls they do not have a class name. MFC works around this by
providing a Windows class, VBControl, which it can use to create VBX
controls. The VBControl class is used as the class name in the dialog
template for every VBX control used in the dialog.
When the application that calls the DLL calls the EnableVBX()
function, it registers the VBControl window class with Microsoft
Windows. The VBControl class is registered as a local window class,
not as a global window class. A local window class is available only
to the module in which the class is registered. Because a DLL has its
own module that is different from the calling application, the VBControl
class is not available to the DLL.
Workarounds:
[1] The application can call the Create() member function of the CVBControl
class to create the VBX control. Call Create() in the OnInitDialog()
function (for a modal dialog box) or in the OnCreate() function (for
a modeless dialog box).
[2] Re-register the VBControl class in the DLL so that it can be used from
the DLL. Also, change the resorce instance handle during the
OnInitDialog() function so that resource in the DLL will be used while
the controls are being created.
This second method is demontrated in the sample.
December 10, 2017
Add comments