2005大懒虫

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
View Code
  1 .386
  2 .model flat, stdcall
  3 option casemap: none
  4 
  5 ;++++++++++++++++++++++++++++++++++++++++
  6 include windows.inc
  7 
  8 include kernel32.inc
  9 include user32.inc
 10 include gdi32.inc
 11 
 12 includelib kernel32.lib
 13 includelib user32.lib
 14 includelib gdi32.lib
 15 ;+++++++++++++++++++++++++++++++++++++++++
 16 DrawEvent    equ    10000h
 17 ;+++++++++++++++++++++++++++++++++++++++++
 18 .data
 19 ;+++++++++++++++++++++++++++++++++++++++++
 20 hInst            HINSTANCE    ?
 21 szClassName        db    'MyClass',0
 22 szWindowName    db    'First Window',0
 23 
 24 szOut    db    20 dup(0)
 25 szFmt    db    '%d:%d:%d',0
 26 ;+++++++++++++++++++++++++++++++++++++++++
 27 .code
 28 ;++++++++++++++++++++++++++++++++++++++++++
 29 ;TimerProc
 30 ;++++++++++++++++++++++++++++++++++++++++++
 31 _TimerProc    proc _hwnd:HWND,
 32                  _uMsg:DWORD,
 33                  _idEvent:DWORD,
 34                  _dwTime:DWORD
 35                  
 36             push TRUE
 37             push NULL
 38             push _hwnd
 39             call InvalidateRect
 40             
 41             ret
 42 _TimerProc    endp
 43 ;++++++++++++++++++++++++++++++++++++++++++
 44 ;WindowProc
 45 ;++++++++++++++++++++++++++++++++++++++++++
 46 _WindowProc    proc _hwnd:HWND,
 47                  _uMsg:DWORD,
 48                  _wParam:WPARAM,
 49                  _lParam:LPARAM
 50             local @stSysTime:    SYSTEMTIME
 51             local @stPs:        PAINTSTRUCT
 52             local @hdc:            HDC
 53             
 54             .if    _uMsg == WM_CREATE
 55                 
 56                 push offset _TimerProc
 57                 push 1000
 58                 push DrawEvent
 59                 push _hwnd
 60                 call SetTimer
 61                 
 62             .elseif _uMsg == WM_PAINT
 63                 
 64                 lea eax, @stPs
 65                 push eax
 66                 push _hwnd
 67                 call BeginPaint
 68                 mov @hdc, eax
 69                 
 70                 lea eax, @stSysTime
 71                 push eax
 72                 call GetSystemTime
 73                 
 74                 movzx eax, @stSysTime.wSecond
 75                 push eax
 76                 movzx eax, @stSysTime.wMinute 
 77                 push eax                
 78                 movzx eax, @stSysTime.wHour
 79                 add eax, 8
 80                 push eax
 81                 push offset szFmt
 82                 push offset szOut
 83                 call wsprintf
 84                 add esp, 20 
 85                 
 86                 push offset szOut
 87                 call lstrlen
 88                 
 89                 push eax
 90                 push offset szOut
 91                 push 100
 92                 push 120
 93                 push @hdc
 94                 call TextOut                
 95                 
 96                 lea eax, @stPs
 97                 push eax
 98                 push _hwnd
 99                 call EndPaint
100                 
101             .elseif _uMsg == WM_CLOSE
102                 
103                 push 0
104                 call PostQuitMessage
105                 
106             .else
107                 
108                 push _lParam
109                 push _wParam
110                 push _uMsg
111                 push _hwnd
112                 call DefWindowProc
113                 
114                 
115             .endif
116             
117             
118             ret
119 
120 _WindowProc    endp
121 ;++++++++++++++++++++++++++++++++++++++++++
122 ;WinMain
123 ;++++++++++++++++++++++++++++++++++++++++++
124 _WinMain    proc _hInst:HINSTANCE, 
125                  _hPrev:HINSTANCE, 
126                  _lpCmdLine:LPSTR, 
127                  _nCmdShow:DWORD
128 
129             local @stWndClass:    WNDCLASSEX
130             local @hWnd:        HWND
131             local @stMsg:        MSG
132             
133             mov @stWndClass.cbSize, sizeof WNDCLASSEX
134             mov @stWndClass.style, CS_HREDRAW or CS_VREDRAW
135             mov @stWndClass.lpfnWndProc, offset _WindowProc
136             mov @stWndClass.cbClsExtra, 0
137             mov @stWndClass.cbWndExtra, 0
138             
139             push _hInst
140             pop @stWndClass.hInstance
141             
142             push IDI_APPLICATION
143             push NULL
144             call LoadIcon
145             mov @stWndClass.hIcon, eax
146             
147             push IDC_ARROW
148             push NULL
149             call LoadCursor
150             mov @stWndClass.hCursor, eax
151             
152             push GRAY_BRUSH
153             call GetStockObject
154             mov @stWndClass.hbrBackground, eax
155             
156             mov @stWndClass.lpszMenuName, NULL
157             
158             push offset szClassName
159             pop @stWndClass.lpszClassName
160 
161             mov @stWndClass.hIconSm, NULL
162 
163             lea eax, @stWndClass
164             push eax
165             call RegisterClassEx
166 
167             ;or eax, eax
168             ;jz __End
169             .if !eax
170                 ret
171             .endif
172                 
173             push NULL
174             push _hInst
175             push NULL
176             push NULL
177             push 300
178             push 400
179             push 0
180             push CW_USEDEFAULT
181             push WS_OVERLAPPEDWINDOW
182             push offset szWindowName
183             push offset szClassName
184             push 0
185             call CreateWindowEx
186             
187             .if !eax
188                 ret
189             .endif
190             mov @hWnd, eax
191             
192             push _nCmdShow
193             push eax
194             call ShowWindow
195 
196             .if eax
197                 ret
198             .endif
199             
200             push @hWnd
201             call UpdateWindow
202             
203             .if    !eax
204                 ret
205             .endif
206                 
207             push 0
208             push 0
209             push NULL
210             lea eax, @stMsg
211             push eax
212             call GetMessage
213             
214             .while eax || eax == -1
215                 lea eax, @stMsg
216                 push eax
217                 call TranslateMessage
218                 
219                 lea eax, @stMsg
220                 push eax
221                 call DispatchMessage
222                 
223                 push 0
224                 push 0
225                 push NULL
226                 lea eax, @stMsg
227                 push eax
228                 call GetMessage
229             .endw
230                 
231             ret
232             
233 _WinMain    endp
234 ;+++++++++++++++++++++++++++++++++++++++++++++
235 start:
236     push NULL
237     call GetModuleHandle
238     mov hInst, eax
239     
240     push SW_SHOWNORMAL
241     push NULL
242     push NULL
243     push hInst
244     call _WinMain 
245 
246     push 0
247     call ExitProcess
248 ;++++++++++++++++++++++++++++++++++++++++++
249 
posted on 2011-03-28 22:14  2005大懒虫  阅读(148)  评论(0)    收藏  举报