FIX: Palette Does Not Change with Picture on MDI Child (149233)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q149233 SYMPTOMS
Changing from one 256-color bitmap to another 256-color bitmap at run time
causes the second bitmap to be rendered with the palette from the first
bitmap. This causes the second bitmap to look wrong, unless both bitmaps
have similar or identical colors. This problem occurs only when the picture
or image control resides on an MDI child form.
RESOLUTION
To work around this problem, send a WM_QUERYNEWPALETTE message to the MDI
child form immediately after changing the bitmap. Follow these steps to
implement this fix: - Add a single module to the project to hold the declaration for
SendMessage and the WM_QUERYNEWPALETTE constant. If a module already
exists in the project it can be used instead of adding a new one.
- Add the following function and constant declarations for the appropriate
bitness to the module:
For Win16 or Win32:
Public Const WM_QUERYNEWPALETTE = &H30F
For Win32 (only):
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Long) As Long
For Win16 (only):
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, _
ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long
- Immediately after the code where the bitmap is changed, add this single
call to SendMessage (assuming Form1 is the MDI child where the picture
or image control is located):
SendMessage Form1.hWnd, WM_QUERYNEWPALETTE, 0, 0
When the form receives this message it will correctly set the palette so
that the new image is displayed correctly. These declarations were
obtained from the 16-bit and 32-bit versions of the API Text Viewer.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug has been fixed in Visual Basic
6.0.
Modification Type: | Major | Last Reviewed: | 6/24/2004 |
---|
Keywords: | kbbug kbfix KB149233 |
---|
|