Progressbar.Asm
上传用户:fuliyuan
上传日期:2021-10-16
资源大小:10k
文件大小:4k
- .386
- .model flat,stdcall
- option casemap:none
- include Progressbar.inc
- .code
- start:
- invoke GetModuleHandle,NULL
- mov hInstance,eax
- invoke GetCommandLine
- invoke InitCommonControls
- mov iccex.dwSize,sizeof INITCOMMONCONTROLSEX ;prepare common control structure
- mov iccex.dwICC,ICC_DATE_CLASSES
- invoke InitCommonControlsEx,addr iccex
- invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
- invoke ExitProcess,eax
- WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
- LOCAL wc:WNDCLASSEX
- LOCAL msg:MSG
- mov wc.cbSize,SIZEOF WNDCLASSEX
- mov wc.style,CS_HREDRAW or CS_VREDRAW
- mov wc.lpfnWndProc,OFFSET WndProc
- mov wc.cbClsExtra,NULL
- mov wc.cbWndExtra,DLGWINDOWEXTRA
- push hInst
- pop wc.hInstance
- mov wc.hbrBackground,COLOR_BTNFACE+1
- mov wc.lpszMenuName,OFFSET MenuName
- 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 CreateDialogParam,hInstance,addr DlgName,NULL,addr WndProc,NULL
- invoke ShowWindow,hWnd,SW_SHOWNORMAL
- invoke UpdateWindow,hWnd
- .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 hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
- LOCAL buffer[256]:BYTE
- mov eax,uMsg
- .if eax==WM_INITDIALOG
- push hWin
- pop hWnd
-
- ;/* progressbar setup */
- invoke GetDlgItem,hWin,1001
- mov hwndProgress,eax
-
- mov eax,1000
- mov CurrentStep,eax
- shl eax,16 ;/* Shift Logical Left , Usage:SHL dest,count */
- invoke SendMessage,hwndProgress,PBM_SETRANGE,0,eax
- invoke SendMessage,hwndProgress,PBM_SETSTEP,10,0
-
- ;/*Percent static setup */
- mov eax,0
- mov Done,eax
-
- invoke GetDlgItem,hWin,1003
- mov hwndStatus,eax
-
- ;/*setup timer*/
- invoke SetTimer,hWnd,IDC_TIMER,100,NULL
- mov TimerID,eax
-
- invoke GetDlgItem,hWin,2001
- mov hBTN1,eax
-
- invoke GetDlgItem,hWin,2002
- mov hBTN2,eax
-
- .elseif eax==WM_TIMER
- invoke SendMessage,hwndProgress,PBM_STEPIT,0,0
- sub CurrentStep,10
-
- ;/*Static update */
- add Done,1
- invoke dwtoa,Done,addr buffer
- invoke lstrcat,addr buffer, offset Percent
- invoke SendDlgItemMessage,hWin,1002,WM_SETTEXT,0,addr buffer
- ;/*End of static update */
-
- .if CurrentStep==0
- invoke KillTimer,hWnd,TimerID
- mov TimerID,0
- invoke SendMessage,hwndStatus,SB_SETTEXT,0,offset Message
- invoke MessageBox,hWnd,offset Message,offset AppName,MB_OK+MB_ICONINFORMATION
- invoke SendMessage,hwndStatus,SB_SETTEXT,0,0
- invoke SendMessage,hwndProgress,PBM_SETPOS,0,0
- .endif
-
- .elseif eax==WM_COMMAND
- mov eax,wParam
- and eax,0FFFFh
- .if eax==IDM_FILE_EXIT
- invoke SendMessage,hWin,WM_CLOSE,0,0
- .elseif eax==IDM_HELP_ABOUT
- invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
- .elseif eax==IDC_BTN1
- invoke SetTimer,hWnd,TimerID,100,NULL
- invoke EnableWindow,hBTN1,FALSE
- invoke EnableWindow,hBTN2,TRUE
- .elseif eax==IDC_BTN2
- invoke KillTimer,hWnd,TimerID
- invoke EnableWindow,hBTN1,TRUE
- invoke EnableWindow,hBTN2,FALSE
- .endif
- .elseif eax==WM_CLOSE
- .if TimerID!=0
- invoke KillTimer,hWnd,TimerID
- .endif
- invoke DestroyWindow,hWin
- .elseif eax==WM_DESTROY
- invoke PostQuitMessage,NULL
- .else
- invoke DefWindowProc,hWin,uMsg,wParam,lParam
- ret
- .endif
- xor eax,eax
- ret
- WndProc endp
- end start