Progressbar.Asm
上传用户:fuliyuan
上传日期:2021-10-16
资源大小:10k
文件大小:4k
源码类别:

状态条

开发平台:

Asm

  1. .386
  2. .model flat,stdcall
  3. option casemap:none
  4. include Progressbar.inc
  5. .code
  6. start:
  7. invoke GetModuleHandle,NULL
  8. mov    hInstance,eax
  9. invoke GetCommandLine
  10. invoke InitCommonControls
  11. mov iccex.dwSize,sizeof INITCOMMONCONTROLSEX     ;prepare common control structure
  12. mov iccex.dwICC,ICC_DATE_CLASSES
  13. invoke InitCommonControlsEx,addr iccex
  14. invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  15. invoke ExitProcess,eax
  16. WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
  17. LOCAL wc:WNDCLASSEX
  18. LOCAL msg:MSG
  19. mov wc.cbSize,SIZEOF WNDCLASSEX
  20. mov wc.style,CS_HREDRAW or CS_VREDRAW
  21. mov wc.lpfnWndProc,OFFSET WndProc
  22. mov wc.cbClsExtra,NULL
  23. mov wc.cbWndExtra,DLGWINDOWEXTRA
  24. push hInst
  25. pop wc.hInstance
  26. mov wc.hbrBackground,COLOR_BTNFACE+1
  27. mov wc.lpszMenuName,OFFSET MenuName
  28. mov wc.lpszClassName,OFFSET ClassName
  29. invoke LoadIcon,NULL,IDI_APPLICATION
  30. mov wc.hIcon,eax
  31. mov wc.hIconSm,eax
  32. invoke LoadCursor,NULL,IDC_ARROW
  33. mov wc.hCursor,eax
  34. invoke RegisterClassEx,addr wc
  35. invoke CreateDialogParam,hInstance,addr DlgName,NULL,addr WndProc,NULL
  36. invoke ShowWindow,hWnd,SW_SHOWNORMAL
  37. invoke UpdateWindow,hWnd
  38. .while TRUE
  39. invoke GetMessage,addr msg,NULL,0,0
  40.   .BREAK .if !eax
  41. invoke TranslateMessage,addr msg
  42. invoke DispatchMessage,addr msg
  43. .endw
  44. mov eax,msg.wParam
  45. ret
  46. WinMain endp
  47. WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
  48. LOCAL buffer[256]:BYTE
  49. mov eax,uMsg
  50. .if eax==WM_INITDIALOG
  51. push hWin
  52. pop hWnd
  53. ;/* progressbar setup */
  54. invoke GetDlgItem,hWin,1001
  55. mov hwndProgress,eax
  56. mov eax,1000
  57. mov CurrentStep,eax
  58. shl eax,16 ;/* Shift Logical Left , Usage:SHL     dest,count */
  59. invoke SendMessage,hwndProgress,PBM_SETRANGE,0,eax
  60. invoke SendMessage,hwndProgress,PBM_SETSTEP,10,0
  61. ;/*Percent static setup */
  62. mov eax,0
  63. mov Done,eax
  64. invoke GetDlgItem,hWin,1003
  65. mov hwndStatus,eax
  66. ;/*setup timer*/
  67. invoke SetTimer,hWnd,IDC_TIMER,100,NULL
  68. mov TimerID,eax
  69. invoke GetDlgItem,hWin,2001
  70. mov hBTN1,eax
  71. invoke GetDlgItem,hWin,2002
  72. mov hBTN2,eax
  73. .elseif eax==WM_TIMER
  74. invoke SendMessage,hwndProgress,PBM_STEPIT,0,0
  75. sub CurrentStep,10
  76. ;/*Static update */
  77. add Done,1
  78. invoke dwtoa,Done,addr buffer
  79. invoke lstrcat,addr buffer, offset Percent
  80. invoke SendDlgItemMessage,hWin,1002,WM_SETTEXT,0,addr buffer
  81. ;/*End of static update */
  82. .if CurrentStep==0
  83. invoke KillTimer,hWnd,TimerID
  84. mov TimerID,0
  85. invoke SendMessage,hwndStatus,SB_SETTEXT,0,offset Message
  86. invoke MessageBox,hWnd,offset Message,offset AppName,MB_OK+MB_ICONINFORMATION
  87. invoke SendMessage,hwndStatus,SB_SETTEXT,0,0
  88. invoke SendMessage,hwndProgress,PBM_SETPOS,0,0
  89. .endif
  90. .elseif eax==WM_COMMAND
  91. mov eax,wParam
  92. and eax,0FFFFh
  93. .if eax==IDM_FILE_EXIT
  94. invoke SendMessage,hWin,WM_CLOSE,0,0
  95. .elseif eax==IDM_HELP_ABOUT
  96. invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
  97. .elseif eax==IDC_BTN1
  98. invoke SetTimer,hWnd,TimerID,100,NULL
  99. invoke EnableWindow,hBTN1,FALSE
  100. invoke EnableWindow,hBTN2,TRUE
  101. .elseif eax==IDC_BTN2
  102. invoke KillTimer,hWnd,TimerID
  103. invoke EnableWindow,hBTN1,TRUE
  104. invoke EnableWindow,hBTN2,FALSE
  105. .endif
  106. .elseif eax==WM_CLOSE
  107. .if TimerID!=0
  108. invoke KillTimer,hWnd,TimerID
  109. .endif
  110. invoke DestroyWindow,hWin
  111. .elseif eax==WM_DESTROY
  112. invoke PostQuitMessage,NULL
  113. .else
  114. invoke DefWindowProc,hWin,uMsg,wParam,lParam
  115. ret
  116. .endif
  117. xor    eax,eax
  118. ret
  119. WndProc endp
  120. end start