Article ID: 108316
Article Last Modified on 3/7/2005
GetObject(hBitmap, 16, &Bitmap);rather than:
GetObject(hBitmap, sizeof(BITMAP), &Bitmap);Unfortunately, the size of the BITMAP structure under Windows 3.1 is 14 bytes, so each such call to GetObject overwrites the variable after Bitmap. Depending on what that variable is, this code could produce a wide range of erratic behavior.
BOOL bTrack = FALSE; // TRUE if user is selecting a region.(Note that both Bitmap and bTrack are global.) Because bTrack is set to TRUE only while the mouse button is down, and the GetObject calls are done only during initialization and when a menu item is selected (which can't be done with the mouse button down), this problem becomes apparent only when the user modifies the code (for example by adding some other variable after Bitmap).
GetObject(hBitmap, sizeof(BITMAP), &Bitmap).
Additional query words: 3.10 docerr
Keywords: kbdocfix KB108316