about showwindow

In early Windows version, the window is not be shown immediately after ShowWindow called, only idle or UpdateWindow called, it will be shown immediately. But in Vista, the window is shown immediately after showwindow called. Because it, the black will flash in the window. How to reslove it? Thanks.
[299 byte] By [catman123] at [2008-2-6]
# 1

I tested ShowWindow in several ways - a main program window, child windows, dialog boxes. I set breakpoints to follow the step-by-step results of ShowWindow (WM_ERASEBKGND, WM_PAINT, WM_SHOWWINDOW...).

Vista is working O.K. in my tests.

I don't know what language you are using to program. My tests were with plain "C" code.

Maybe something to help: (?)
1) If you register your own class for this window, Check the "hbrBackground" setting that you register. If you want a normal background color, it should be "COLOR_WINDOW + 1".
2) If you handle the WM_ERASEBKGND message for the window, be sure your brush is initialized properly and you are returning a non-zero value.

If this doesn't help, please tell us more about what language you are programming with, and what type of window is displaying the flash of black.

LenGray-Eclipsit at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 2

Thanks for your help.

I using Microsoft Vistual C++ 6.0 with windows SDK.

I want to create a window and show a picture on the window on WM_PAINT.

The hbrBackground of window class is NULL.

I create the window, then show it by calling ShowWindow. You can set the breakpoint on ShowWindow. After ShowWindow called, Immedialitly on the desktop a window is shown with black background. It is defferent with Windows XP and 2000. Under Windows XP and before, window client region will not be paint with black background.

catman123 at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...
# 3

When hbrBackground is set to NULL, you are supposed to process the erasing of the background. MSDN documentation indicates:

"If hbrBackground is NULL, the application should process the WM_ERASEBKGND message and erase the background. "

If your picture covers the entire window client area, you could process the WM_ERASEBKGND message and show your picture? The wParam field provides the DC to paint to. Show the picture and then return a non-zero value to indicate you handled the background painting.

Does this help?

LenGray-Eclipsit at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,UI Development for Windows Vista...

Software Development for Windows Vista

Site Classified