|
楼主 |
发表于 2013-10-31 19:42:37
|
显示全部楼层
.386 ;1
.model flat,stdcall ;2
option casemap:none ;3
;///////////////////////////////////////////// ;5
include windows.inc ;6
include gdi32.inc ;7
includelib gdi32.lib ;8
include user32.inc ;9
includelib user32.lib ;10
include kernel32.inc ;11
includelib kernel32.lib ;12
;////////////////////////////////////////////////////
.const
szClassName db 'FirstWindow',0
szCaption db 'Hello Window',0
szText db 'haha',0
;/////////////////////////////////////////////////////
.data?
hWinMain dd ? ;20
hInstance dd ? ;21
;////////////////////////////////////////////////////
_ProcWinMain proc uses eax ebx edi esi,hWnd,uMsg,wParam,lParam
local @stPs:PAINTSTRUCT ;24
local @stRect:RECT ;25
local @hDc ;26
mov eax,uMsg ;27
.if eax==WM_PAINT ;28
invoke BeginPaint,hWnd,addr @stPs ;29
mov @hDc,eax ;30
invoke GetClientRect,hWnd,addr @stRect ;31
invoke DrawText,@hDc,addr szText,-1,addr @stRect,DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint,hWnd,addr @stPs ;33
;34
.elseif eax ==WM_CLOSE ;35
invoke DestroyWindow,hWinMain ;36
invoke PostQuitMessage,NULL ;37
.else ;38
invoke DefWindowProc,hWnd,uMsg,wParam,lParam ;39
ret ;40
.endif ;41
xor eax,eax
ret
_ProcWinMain endp ;45
;///////////////////////////////////////////////////////////////
_WinMain proc
local @stWndClass:WNDCLASSEX ;49
local @stMsg:MSG ;50
invoke GetModuleHandle,NULL ;51
mov hInstance,eax ;52
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
;54
invoke LoadCursor,0,IDC_ARROW ;55
mov @stWndClass.hCursor,eax
push hInstance
pop @stWndClass.hInstance
mov @stWndClass.cbSize,sizeof WNDCLASS
mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW
mov @stWndClass.lpfnWndProc,offset _ProcWinMain
mov @stWndClass.hbrBackground,COLOR_WINDOW+1
mov @stWndClass.lpszClassName,offset szClassName
invoke ResgisterClassEx,addr @stWndClass ;64
;mov hWinMain,eax ;65
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szCaption,\
WS_OVERLAPPEDWINDOW,100,100,600,400,NULL,NULL,hInstance,NULL
mov hWinMain,eax ;68
invoke ShowWindow,hWinMain,SW_SHOWNORMAL ;69
invoke UpdateWindow,hWinMain ;70
.while TURE ;71
invoke GetMessage,addr @stMsg,NULL,0,0
.break .if eax==0
invoke TranslataMessage,addr @stMsg ;74
invoke DispatchMessage,addr @stMsg
.endw ;76
ret
_WinMain endp
;////////////////////////////////////////////////////////////
start: call _WinMain ;81
invoke ExitProcess,NULL
end start |
|