-
Wm_paint
I have a window and its client area is filled with a bitmap patterned brush. It also contains several transparent static controls which I am using as frames for bitmap images.
I can paint the client area with the brush and paint the images into the static controls with no problem, however, when the WM_PAINT message is sent to my window it only manages to repaint the client area and not the bitmaps inside my static controls
My code looks like this:
--------------------------------------------
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
PaintTableMat(hdc, hwnd);
EndPaint(hwnd, &ps);
ShowDeal();
}
break;
--------------------------------------------
PaintTableMat() and ShowDeal() are the functions to paint the background and the framed images; they both work fine outside of the WM_PAINT context but ShowDeal() (the function to paint the images into the static controls) doesnt work here and it leaves the screen with grey rectangles where the images should be!
Hmf :(
I'm guessing that the static controls need to process their own WM_PAINT messages(?!) but I really don't have a clue, I would be very grateful if anyone could help!
thanks for listening
dom
-
Look up GetWindowLong in MSDN it should do what you want. You can get the WndProc for the static controls and replace them with your own.
-
Also could be that the HDC returned from BeginPaint() is that of the invalidated area (from a UpdateWindow() or InvalidateRect() ) and does not include the statics client area.
A frame buffer system could work better. All drawing is done to a HDC buffer. A copy is kept and updated when the drawing is finished.
On a WM_PAINT msg the copy is drawn to the screen. At no stage is the buffer drawn to the screen. This means that the paint is smooth, fast and that the whole area does not have to be invalidated to draw correctly. It also means that the screen can be redraw while there is drawing going on to the buffer in the background.
Use this to find the area to redraw in your WM_PAINT _before_ the call to BeginPaint() validates the drawing area.
Code:
GetUpdateRect(hWnd, &theRect, 0);
if (IsRectEmpty(&theRect))
{
GetClientRect(hWnd,&theRect);
}
-
THANKS!
Thanks guys! It is now daylight and (07:47) I've just managed to fix it!
I set the WndProc of the static controls to the same one as the main window an it worked. (It took me so long cos I had to figure out how to do that, I've only been doing API for a couple of days).
Anyways,
much gratitude ;-)