[windev] scrolling windows and device contexts and such...

Stephen Hazel stephen.hazel at gmail.com
Sat Mar 7 19:33:12 GMT 2009


Env: msvc7?  (2002); c++; Win32 (no MFC); XP,etc

Ok, I need the help of you win32 gurus again.

my app is displaying bitmaps of scanned sheet music.
A bitmap per page of sheet music.  (well, a bitmap per half page of music).
I display 2 at a time StretchBlt'd to top and bottom halves of a window.

I need to scroll the next one in smoothly so you don't lose your place.

And I need the scrolling to not burn much cpu.
I'm in a pretty tight midi event dumping loop.

Now, if i understand win32 correctly, a display device context has no size
 beyond what's currently displayed on the monitor.
You can scroll a window and what's there gets scooted, but the "moved from" area
is just invalidated and the code called by wm_paint redraws it.

So there's no such thing as a "bigger canvas" that's larger than the
window and you
just say "scroll!" and wherever the window is positioned over the canvas, bam,
it's done for you.

So the way you do it is a memory device context that has a bitmap that holds
this "full canvas of bits" and wherever you scroll to, you calc the area of
this memory device context that's SHOWing and you blt it on screen.

I might StretchBlt 3 bitmaps into the memory device context+bitmap then
do a scrollwindowex() (no erase,no inval) and straight blt of new area?

Am I on the right track here?

Does anybody know if ScrollWindowEx's smooth scrolling option comes back
immediately or comes back after the scroll delay time has passed?

My app has 2 threads - the main gui one and a midi processing loop one.
I might have to move the scrolling to the gui thread somehow.
Now, I'm StretchBlt'ing the 2 bitmap halves repeatedly to scroll
and it's sucking cpu :(
(I guess that's for me to deal with)

Thanks much for any ideas :)

...Steve


More information about the Windev mailing list