PRB: ActiveDesktop Compilation Errors Under Visual C++ 6.0 MFC
Article ID: 196342
Article Last Modified on 6/18/2001
APPLIES TO
- Microsoft Internet Explorer 4.0 128-Bit Edition
- Microsoft Internet Explorer 4.01 Service Pack 2
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q196342
SYMPTOMS
Under Visual C++ 6.0 Microsoft Foundation Classes (MFC), compiling code
related to the IActiveDesktop interface will fail with multiple errors,
including an "undeclared identifier" for LPACTIVEDESKTOP.
Note that this occurs specifically when compiling an MFC program using
Visual C++ 6.0. There is no report of the problem occurring in previous
versions of MFC or in the general Visual C++ 6.0 case where C or C++
programs are being compiled.
CAUSE
When an MFC application includes the Stdafx.h header file, the file
*\Vc98\Mfc\Include\Afxdisp.h is included by default. Within Afxdisp.h the
file Shlobj.h (required for ActiveDesktop) is included. But at this point,
Wininet.h has not been included, so certain portions of Shlobj.h are not
correctly initialized for ActiveDesktop support.
The inclusion of Shlobj.h by Afxdisp.h also sets a variable preventing
Shlobj.h from being included twice. Later, when an MFC application
explicitly and correctly includes Wininet.h followed by Shlobj.h, the
previously set variable prevents the second Shlobj.h inclusion and also
prevents critical ActiveDesktop definitions, such as for LPACTIVEDESKTOP,
from being made.
RESOLUTION
Add a #include for the Wininet.h header to the Stdafx.h precompiled header
file, just above the Afxdisp.h include. Here's an example of Stdafx.h:
// stdafx.h : include file for standard system include files,
...
#include <wininet.h>
#include <afxdisp.h> // MFC Automation classes
...
#endif //!defined(AFX_STDAFX_H__D5E466A9...
After correcting Stdafx.h, rebuild the entire project to ensure that the
precompiled header is re-compiled.
Keywords: kbactivedesktop kbprb KB196342