My current experiment is to have a window with some random text/lines painted to it, and automatically scroll it around (without scroll bars). I started off having a timer that posts a WM_VSCROLL message, and then the window procedure uses ScrollWindowEx to shift the window. What i'm having trouble with is repainting the window correctly; it doesn't seem to want to send paint messages at all after ScrollWindowEx even though I have UpdateWindow right after it, and whenever it does repaint the window, it always starts over at the top-most, left-most origin. I'm guessing theres an API call for this, but seraching has yet to yield any results...I tried OffsetViewportOrgEx with no success. Any design suggestions are always welcome
alan
create window get DC from gdi,create bitmap with text and scroll it, or just draw to bitmap,and refresh, you do with InvalidateRect, where you define ractangle to redraw or RedrawWindow
cmp eax,WM_PAINT
jne nopaint
call BeginPaint,[hWnd],o ps
call BitBlt,eax,0,75,640,256,[hBackDC],0,shit,SRCCOPY
call EndPaint,[hWnd],o ps
nopaint:
cmp eax,WM_VSCROLL
je _wmvscroll
cmp eax,WM_MOUSEWHEEL
je _wmmousewheel
cmp eax,WM_DESTROY
je _wmdestroy
cmp eax,WM_CLOSE
je _wmdestroy
cmp eax,WM_COMMAND
je _wmcommand
cmp eax,WM_LBUTTONDOWN
jne unknown
call SendMessage,[hWnd],WM_NCLBUTTONDOWN,HTCAPTION,0
unknown:
xor eax,eax
ret
_wmvscroll:
mov eax,[wparam]
mov ebx,[scinfo.nPos]
cmp ax,SB_THUMBTRACK
jne maybe_sb_linedown
mov ebx,eax
shr ebx,16
maybe_sb_linedown:
cmp ax,SB_LINEDOWN
jne maybe_sb_lineup
add ebx,8
maybe_sb_lineup:
cmp ax,SB_LINEUP
jne maybe_sb_pagedown
sub ebx,8
maybe_sb_pagedown:
cmp ax,SB_PAGEDOWN
jne maybe_sb_pageup
add ebx,256
maybe_sb_pageup:
cmp ax,SB_PAGEUP
jne _setscrollinfo
sub ebx,256
_setscrollinfo:
or ebx,ebx
jnl scroll_min_ok
xor ebx,ebx
scroll_min_ok:
cmp ebx,ScrollBar
jng scroll_max_ok
mov ebx,ScrollBar
scroll_max_ok:
mov [scinfo.nPos],ebx
mov shit,ebx
call SetScrollInfo,hScroll,SB_CTL,o scinfo,1
call RedrawWindow,[hWnd],o DrawRect,0,1
ret
_wmmousewheel:
mov eax,[wparam]
mov ebx,SB_PAGEUP
test eax,80000000h
je wheel_up
mov ebx,SB_PAGEDOWN
wheel_up:
call SendMessage,[hWnd],WM_VSCROLL,ebx,0
ret
The tricky part is, in the general case, you don't know when a WM_PAINT message will be sent. When the WM_PAINT message is sent, its routine will do its painting job on top of any other painting you've done. One specific case, an InvalidateWindow followed by an UpdateWindow will immediately trigger a WM_PAINT message.
One way to manage your graphics is to structure code to generate all graphics when you get WM_PAINT. This means "caching" information needed to create the display, and using the cached information during WM_PAINT.
Another way is to use a back buffer to hold the image you want to display, and bitblit it when WM_PAINT is sent. You make all your "immediate" changes to the back buffer.
There may be other ways as well.