Hi,

Yep I've done it. But my implementation SUCKS and breaks a few things so I
won't commit yet.

First, the HOW:

Before you read on, be prepared for nastiness.

When WM_ERASEBKGND is received in CommonMsgLoop it is discarded (so we stop
backround erasing happening).

When WM_PAINT is received in CommonMsgLoop a compatible DC and bitmap for
the window is created, and the DC handle is then sent back to the window in
a WM_PRINT message for drawing (WM_PRINT can be sent to make the window do
it's drawing in another DC). Now the DC that's just been WM_PRINTed on is
blitted back onto the window's DC.

Here are the problems:
1.    WM_PRINTCLIENT didn't do what I wanted (I expected it would draw
everything in the client area on a bitmap the size of the client area, but
this didn't want to work) so I had to use WM_PRINT, and do some sums to
calculate how to crop the resultant bitmap, which included blank areas for
the non-client-area.

2.    It's kind of slow. This is probably because it has to create a DC and
bitmap every time a WM_PAINT occurs, and it has to draw the whole window
(which it was doing anyway). It also does FillRect to clear the background
of the new bitmap to the right colour, and I couldnt find a faster way of
doing it than this.

3.    It fills the background of the new DC with the colour for
COLOR_BTNFACE, whatever your OS. This probably looks right on XP too, I
haven't tested it. I tried to use the color set in the window's class using
GetClassLong(hwnd,GCL_HBRBACKGROUND), but this always just returned "5"
rather than a brush handle, which is odd. Incidentally, 5 is the value of
COLOR_WINDOW, which Win32::GUI chooses as the class color on a win2k machine
(like mine) - could this point to a more elegant way of fixing the WinXP
white-background bug, I.e. the class color should be a brush rather than a
color?.

4.    Graphics objects no longer show up (DCs don't seem to support
WM_PRINT).

5.    Setting WS_CLIPCHILDREN results in massive flickering (the opposite of
what it used to do) and causes no background to show.

Despite these 5 points, on my machine it's not NOTICEABLY slow and my GUIs
feel so much more solid with it. Perhaps this feature should be optional?

No commit until I have some of your advice, questions or suggestions.

Steve


Reply via email to