Filed under Issues

Be careful with DECLARE_MESSAGE_MAP()

If you decide to clean up and re- arrange your code, better be careful about the DECLARE_MESSAGE_MAP() macro that will be present in an MFC derived class header file. This macro contains a “protected” storage class declaration. So everything that comes under this macro will be protected unless there is any other storage class specified after that. Normal error that occur during compilation will be cannot access the private variable. But you cannot easily figure out what went wrong you can see only a macro call and a public storage class above.

#ifdef _AFXDLL
#define DECLARE_MESSAGE_MAP() \
private: \
    static const AFX_MSGMAP_ENTRY _messageEntries[]; \
protected: \
    static AFX_DATA const AFX_MSGMAP messageMap; \
    static const AFX_MSGMAP* PASCAL _GetBaseMessageMap(); \
    virtual const AFX_MSGMAP* GetMessageMap() const; \

#else
#define DECLARE_MESSAGE_MAP() \
private: \
    static const AFX_MSGMAP_ENTRY _messageEntries[]; \
protected: \
    static AFX_DATA const AFX_MSGMAP messageMap; \
    virtual const AFX_MSGMAP* GetMessageMap() const; \

#endif

The solution is to leave it inside a protected storage class. i.e, declare a protected storage class just above it and declare the functions and variables that require to be protected, below it. Let the public functions and variables be above the protected section with proper declaration of the storage class.

Tagged , , , , , ,

How to Run Platform SDK Setup on XP 64 Bit

Due to some project requirements, I had to install platform SDK and unfortunately it was an old version: FEB-2003. The OS in my machine was Windows XP 64 bit. When I tried to run the Setup.exe as normal, It showed up an error message: “The image file E:\PlatformSDK\Setup.Exe is valid, but is for a machine type other than the current machine.”. My first thought was like I need to find a 64bit compatible Platform SDK setup, but what I needed wasn’t a 64 bit Platform SDK, but a 32 bit one which need to be installed on my 64 bit XP.

16-bit setup error

After some search, I got to know that the reason for the error is not about 32 bit, 64 bit incompatibility, but the Setup.exe I executed was a 16 bit application. It showed an error because 64 Bit OS doesn’t support 16 bit applications. But when I simply went inside the “setup” folder and ran the “PSDK-x86.msi”, It worked fine! I was able to install Platform SDK.

Now let’s look at checking whether an application is 16-Bit or 32 Bit.  The very simple method is simply right-clicking the executable and checking for the version tab. If it have a version tab, It is a 32-bit (or above) application, else 16-bit.

Tagged , , ,
Follow

Get every new post delivered to your Inbox.

Join 216 other followers