BUG: VTS_UI1 and VTS_PUI1 are defined incorrectly in AfxDisp.h in Visual C++ (242588)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q242588 SYMPTOMS
When using the string literals defined for VTS_UI1 or VTS_PUI1 in calling COleDispatchDriver::InvokeHelper() or CWnd::InvokeHelper(), you might get strange results. You might notice any of the following symptoms when using the values defined in AfxDisp.h:
- An ASSERT on line 321 in file Oledisp2.cpp in the COleDispatchDriver::InvokeHelperV function.
- A message box stating "Bad variable type."
- An uncaught exception in WindowProc.
- A first chance exception in Kernel32.dll.
CAUSE
This is because VTS_UI1 and VTS_PUI1 are defined incorrectly in the Afxdisp.h header file.
RESOLUTION
Do not use VTS_UI1 or VTS_PUI1 in any of your code. Instead, define the correct values for each of these using a name you assign. Code like the following can be used:
//Do NOT use VTS_UI1. It has a value of "0x0F" which is incorrect.
//The correct value for VTS_UI1 is 17 or 0x11
#define MY_VTS_UI1 "\x11"
//Do NOT use VTS_PUI1. It has a value of "0x4F" which is incorrect.
//The correct value for VTS_PUI1 is 81 or 0x51
#define MY_VTS_PUI1 "\x51"
void SomeFunction(BYTE byteVal)
{
static BYTE parms[] = MY_VTS_UI1; // please note that this is not VTS_UI1
DISPID dispid = 0x60030000; // notice that this is different!
COleDispatchDriver d;
if (d.CreateDispatch("SomeComObject.SomeComObject.1))
d.InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, NULL, parms, byteVal);
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. REFERENCES241862 BUG: ClassWizard Omits Methods that Take BYTE or BYTE* as Parameters
| Modification Type: | Major | Last Reviewed: | 6/2/2005 |
|---|
| Keywords: | kbtshoot kbAutomation kbBug KB242588 kbAudDeveloper |
|---|
|