Hi,

My application toolbar and status bar flicker on resizing,
so I decided to use double buffering.
A number of threads refer to the ESF example by Chris Hobbs,
which doesn't seem to be available on Iczelions site any more.
Does anyone have a new pointer to it, or can repost it?

So I'm using a memory device context for double buffering my entire
client window. With the WM_PRINTCLIENT API I've managed to
have the status and toolbar window paint itself to my backbuffer.
Then I blit onto my app DC.

This works as expected without any flicker, but as I had to reset
the WM_VISIBLE flag on the child windows (I want to paint/blit them
myself) they "don't work" anymore either...
That is, when I click the space normally taken up by the toolbar buttons,
nothing happens.

How can I leave WM_VISIBLE and still prevent the child windows
from repainting at all?

Also, the status/toolbar paint themselves to (0,0) within my memory DC
on WM_PRINTCLIENT, so I first print the status bar, blit it, print my toolbar,
and blit that. It would be more straightforward if I could give coordinates
within the DC as well.
Has anyony tried sending WM_PAINT with a memory device context to
controls?
Posted on 2003-01-02 06:00:58 by Gluco
All the way at the bottom for that esf thingie

I dont know anything about WM_PRINTCLIENT and all that, but I do know that sending WM_PAINT to a window with a hdc as a wParam or lParam will not do anything because wParam and lParam are not used in the WM_PAINT message. The only way this would work is if your app was the one responding to the WM_PAINT messages.
Posted on 2003-01-02 06:48:45 by BubbaFate
The ESF example is still there. Source codes section, at the bottom of page 2.

Dammit, BubbaFate, you beat me :grin:
Posted on 2003-01-02 06:49:24 by Qweerdy
Thanks for the pointer! :alright:
Posted on 2003-01-02 06:53:43 by Gluco
Speaking of flickering windows, has anyone heard of the listview style LVS_EX_DOUBLEBUFFER? I just found out that it existed and its saved me a bit of trouble... but I believe it only works on winxp however =( The value is 10000h btw.
Posted on 2003-01-02 07:36:35 by BubbaFate
I've looked at the ESF tutorial now, but it doesn't show how to draw
windows controls in general onto a backbuffer, and then blit that backbuffer
to screen in one go.

I'm using subclassing now, referring to Iczelion's tut #20 this should look
familiar:

invoke CreateToolbarEx, hWnd, WS_CHILD or WS_CLIPSIBLINGS and not WS_VISIBLE, ....
mov hToolBar, eax
... stuff like adding buttons....
;subclassing, so that child window does NO painting
invoke SetWindowLong, hToolBar, GWL_WNDPROC, addr ToolbarWndProc
mov OldToolbarWndProc, eax
invoke ShowWindow, hToolBar, SW_SHOWNORMAL

Here is the new WndProc function:

ToolbarWndProc PROC hEdit:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg==WM_PAINT
ret
.elseif uMsg==WM_ERASEBKGND
ret
.endif
invoke CallWindowProc, OldToolbarWndProc, hToolBar,uMsg,wParam,lParam
ret
xor eax,eax
ret
ToolbarWndProc endp

As you can see, I'm trapping only WM_PAINT and WM_ERASEBACKGROUND with
an empty handler. This is so that nothing gets output by windows because I
want to blit the child windows using the backbuffer (see further up in thread).

However - the above code produces the following result:
The toolbar is invisible, which is what I want.
It responds to mouse clicks now, which is what I wanted.
:confused: It also deadlocks as soon as I click it, which is the annoying part.
More specifically, the app window isn't active anymore (caption bar changes color)
and is inoperable (sys/menu doesn't work).

Have you got any idea what could be wrong with my ToolbarWndProc ?

It works for the status bar - I can use it's resizing tab although I can't see it.
That's cool, because this means I can just "render" the bar and other windows
stuff onto the back buffer, then blit everything in one go, whilst maintaining standard
windows functionality!
Posted on 2003-01-02 08:33:44 by Gluco
i dunno if this makes a difference but in the following code...

ToolbarWndProc PROC hEdit:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg==WM_PAINT
ret
.elseif uMsg==WM_ERASEBKGND
ret
.endif
invoke CallWindowProc, OldToolbarWndProc, hToolBar,uMsg,wParam,lParam
ret
xor eax,eax
ret
ToolbarWndProc endp

ToolbarWndProc's first argument is hEdit, but when u call CallWindowProc you pass in hToolBar... it seems like that would work... but when I use callwindowproc i always pass the arguments directly from the procedure
Posted on 2003-01-02 09:14:41 by BubbaFate
Thanks BubbaFate,

I know what's wrong now :alright: When subclassing the toolbar,
your ersatz-WndProc must call the toolbars DefWindowProc in its
WM_PAINT handler, which I didn't do:

ToolbarWndProc PROC hToolBarW:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg==WM_PAINT
invoke DefWindowProc, hToolBar, uMsg, wParam, lParam
ret
.elseif uMsg==WM_ERASEBKGND
ret
.else
invoke CallWindowProc, OldToolbarWndProc, hToolBar,uMsg,wParam,lParam
ret
.endif
ToolbarWndProc endp
Posted on 2003-01-02 10:49:32 by Gluco