News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Scroll example

Started by Vortex, July 08, 2012, 07:16:54 PM

Previous topic - Next topic

Vortex

Here is a GUI scroll example :

include Scrolltest.inc

.data

DlgBox  db 'DLGBOX',0
TextMsg db '      This is a scrolling text message ',0
CharPos dd 0

.data?

hBrush    dd ?

.code

start:

    invoke  GetModuleHandle,0
    invoke  DialogBoxParam,eax,ADDR DlgBox,0,ADDR DlgProc,0
    invoke  ExitProcess,eax

DlgProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

LOCAL hdc:DWORD
LOCAL ps:PAINTSTRUCT
LOCAL rc:RECT

    .IF uMsg==WM_INITDIALOG

        invoke    SetTimer,hWnd,ID_TIMER,300,ADDR TimerProc

    .ELSEIF uMsg==WM_CTLCOLORDLG

        invoke   CreateSolidBrush,White
        mov       hBrush,eax
        ret

    .ELSEIF uMsg==WM_CLOSE

        invoke    EndDialog,hWnd,0

    .ELSEIF uMsg==WM_PAINT

        invoke    BeginPaint,hWnd, ADDR ps
        mov       hdc,eax
        invoke    GetClientRect,hWnd,ADDR rc
        mov       rc.left,100
        mov       edx,OFFSET TextMsg
        add       edx,CharPos
        mov       ecx,39
        sub       ecx,CharPos
        invoke    DrawText,hdc,edx,ecx,ADDR rc,0
        invoke    EndPaint,hWnd,ADDR ps

    .ELSE

        xor eax,eax
        ret

    .ENDIF

    mov    eax,TRUE
    ret

DlgProc ENDP

TimerProc PROC hWnd:DWORD,uMsg:DWORD,idEvent:DWORD,dwTime:DWORD

        cmp     CharPos,38
        jne     @f
        invoke  KillTimer,hWnd,ID_TIMER
        ret
@@:
        inc     CharPos
        invoke  InvalidateRect,hWnd,0,TRUE
        ret

TimerProc ENDP

END start