PRB: ActiveDesktop Compilation Errors Under Visual C++ 6.0 MFC

ID: Q196342


The information in this article applies to:


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.

Additional query words:


Keywords          : kbActiveDesktop kbIE400 kbIE401 kbVC600 kbIE401sp1 kbIE500 
Version           : WINDOWS:4.0,4.01,4.01sp1,4.01sp2,5.0dp1,6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 30, 1999