News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Restoring covered window after scroll

Started by afk, August 09, 2007, 12:37:19 PM

Previous topic - Next topic

afk

What is the correct method of restoring a scrolled screen after it's
been covered by another application ?

It seems to me that the system issues WM_PAINT and depends upon the
application's WM_PAINT handler to repeat the last screen paint.

But SCROLLWINDOW(EX) shifts the entire bitmap up/down by (INT dy)
and the application issues a command to redraw only the invalidated
portion of the client area. If the scroll was for line up/down this
means that the last paint command was for only the bottom or top line
of the client. If the window is covered at this point the redraw will
be only for the single invalidated line.

Should I save the window after each line up/down scroll ?
I found a site which describes how to code the following sequence :

CreateCompatibleDC,
CreateCompatibleBitmap,
SelectObject,
GetWindowDC, and
Bltblt.

Would this be considered a good solution ?
Thanks in advance.
afk


Tedd

The usual (easy/lazy) way to do it is simply InvalidateRect for your window, which will cause a WM_PAINT message to be sent and you do your redrawing directly from there.
For a window that updates regularly, using a memory dc (CreateCompatibleDC, etc) as a back-buffer is generally better as it avoids flicker. Though what you should do is create the dc once and keep hold of it, then draw your contents onto that each time, and BitBlt to do the actual update.
When you do a BeginPaint, there's a RECT structure in the PAINTSTRUCT that gives you the area needing to be redrawn - so you can just update that if it would be nicer/less complex -- after ScrollWindow there's usually only a small portion to redraw.
It does depend somewhat on what your application does - as to whether you can get away with clearing and redrawing the whole window each time. But if you're aiming for the more 'professional' method then use the back-buffer (memory dc + BitBlt).
No snowflake in an avalanche feels responsible.

afk

I agree. For the sake of a couple of more APIs I think it's the
most secure method.
Thanks Tedd
afk