WIN32汇编: 18.通用控件[2]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 goddragon 的 blog

    mov   wc.cbclsextra,null
    mov   wc.cbwndextra,null
    push  hinst
    pop   wc.hinstance
    mov   wc.hbrbackground,color_appworkspace
    mov   wc.lpszmenuname,null
    mov   wc.lpszclassname,offset classname
    invoke loadicon,null,idi_application
    mov   wc.hicon,eax
    mov   wc.hiconsm,eax
    invoke loadcursor,null,idc_arrow
    mov   wc.hcursor,eax
    invoke registerclassex, addr wc
    invoke createwindowex,ws_ex_clientedge,addr classname,addr appname,\
ws_overlapped+ws_caption+ws_sysmenu+ws_minimizebox+ws_maximizebox+ws_visible,cw_usedefault,\
           cw_usedefault,cw_usedefault,cw_usedefault,null,null,\
           hinst,null
    mov   hwnd,eax
    .while true
         invoke getmessage, addr msg,null,0,0
        .break .if (!eax)
        invoke translatemessage, addr msg
        invoke dispatchmessage, addr msg
    .endw
    mov eax,msg.wparam
    ret
winmain endp

wndproc proc hwnd:hwnd, umsg:uint, wparam:wparam, lparam:lparam
    .if umsg==wm_create
         invoke createwindowex,null,addr progressclass,null,\
            ws_child+ws_visible,100,\
            200,300,20,hwnd,idc_progress,\
            hinstance,null
        mov hwndprogress,eax
        mov eax,1000               ; the lparam of pbm_setrange message contains the range
        mov currentstep,eax
        shl eax,16                   ; the high range is in the high word
        invoke sendmessage,hwndprogress,pbm_setrange,0,eax
        invoke sendmessage,hwndprogress,pbm_setstep,10,0
        invoke createstatuswindow,ws_child+ws_visible,null,hwnd,idc_status
        mov hwndstatus,eax
        invoke settimer,hwnd,idc_timer,100,null        ; create a timer
        mov timerid,eax
    .elseif umsg==wm_destroy
        invoke postquitmessage,null
        .if timerid!=0
            invoke killtimer,hwnd,timerid
        .endif
    .elseif umsg==wm_timer        ; when a timer event occurs
        invoke sendmessage,hwndprogress,pbm_stepit,0,0    ; step up the progress in the progress bar
        sub currentstep,10
        .if currentstep==0
            invoke killtimer,hwnd,timerid
            mov timerid,0
            invoke sendmessage,hwndstatus,sb_settext,0,addr message
            invoke messagebox,hwnd,addr message,addr appname,mb_ok+mb_iconinformation
            invoke sendmessage,hwndstatus,sb_settext,0,0

本文关键:asm
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top