PRB: CStatic::SetBitmap Doesn't Display Bitmap on Win NT 3.51

Last reviewed: July 10, 1997
Article ID: Q151378
4.00 4.10 WINDOWS NT kbprg kbprb

The information in this article applies to:

  • The Microsoft Foundation Classes, included with: Microsoft Visual C++ for Windows, versions 4.0, 4.1

SYMPTOMS

CStatic::SetBitmap() does not display the bitmap correctly on a picture control in Windows NT 3.51 if the picture control is subclassed.

This problem is restricted to Windows NT 3.51 and does not appear on Windows 95.

RESOLUTION

Do not subclass the picture control either directly, by using SubClassWindow() or SubClassDlgItem(), or indirectly, by associating a CStatic control variable with it. Instead, call SetBitmap() using a pointer to the picture holder obtained by calling GetDlgItem()

STATUS

This behavior is by design.

MORE INFORMATION

Embed a picture control on a dialog, form view, or property page using the resource editor, and associate it with a bitmap type. Change the ID from IDC_STATIC to something else. Associating the picture control with a bitmap ID is optional. Using Class Wizard, associate a CStatic control variable with this picture control. Note that when you try to display a bitmap or change the old bitmap on the picture holder using CStatic::SetBitmap(), the new bitmap is not displayed.

Sample Code

   // IDC_PICHOLD is the picture holder's ID
   ((CStatic*)GetDlgItem(IDC_PICHOLD))->SetBitmap(/* handle to bitmap */);


Additional reference words: 4.00 4.10
KBCategory: kbprg kbprb
KBSubcategory: MfcMisc
Keywords : MfcMisc kbprb kbprg
Technology : kbMfc
Version : 4.00 4.10
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.