ID: Q142350
1.50 1.51 1.52 WINDOWS kbprg kbbuglist kbfixlist
The information in this article applies to:
There's a bug in the MFCVBX sample that's described in the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q123377
TITLE : SAMPLE: MFCVBX Implements a VBX Control Using MFC
The MFCVBX sample shows how to create a VBX control using MFC. If this
sample is used as an approach for creating a VBX control and the
MODEL_fChildrenOk flag is also used, then the VBX control causes a
general protection (GP) fault.
A GP fault could occur for a number of reasons, but in particular it will happen if a combo box is placed on the VBX control.
The sample code does not correctly handle the case where a message handler needs to call the default message procedure. It does not set MFC's internal structure, which stores the previous message. Therefore, when the default message handler is called, it is called with the incorrect message (and parameters).
Modify the CircleCtlProc function located in the Mfcvbx.cpp file in the sample. Make the following changes:
1. Add the following declaration before the CircleCtlProc function:
extern MSG NEAR _afxLastMsg;
2. Make the following modifications to the CircleCtlProc function:
Change this line:
LRESULT lResult = pCtl->WindowProc(msg,wp,lp);
To this code:
MSG oldState = _afxLastMsg;
_afxLastMsg.message = msg;
_afxLastMsg.wParam = wp;
_afxLastMsg.lParam = lp;
LRESULT lResult = pCtl->WindowProc(msg,wp,lp);
_afxLastMsg = oldState;
Microsoft has confirmed this to be a bug in the MFCVBX sample. This problem has been corrected. To obtain the latest version of the sample, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q123377
TITLE : SAMPLE: MFCVBX Implements a VBX Control Using MFC
For more information on the MODEL_fChildrenOk flag and what it is used for, please see:
Visual Basic 3.0:
VB API Reference Help.Data Structures.MODEL Flags
Visual Control Pack 1.0:
VCP CDK Help.Data Structures.MODEL Flags
Additional reference words: 1.50 1.51 1.52b 2.50 2.51 2.52 2.52b vb
CVBControl CDK
KBCategory: kbprg kbbuglist kbfixlist
KBSubcategory: MfcVBX
Keywords : kb16bitonly kbMFC kbVBX kbVC kbbuglist kbfixlist
Version : 1.50 1.51 1.52
Platform : WINDOWS
Solution Type : kbfix
Last Reviewed: September 22, 1997