|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 lyoal 于 2013-2-15 22:25 编辑
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ;基础数据定义
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- .386
- .model flat,stdcall
- option casemap:none
-
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ;所需要的include头文件和导入库
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- include windows.inc
- include user32.inc
- includelib user32.lib
- include kernel32.inc
- includelib kernel32.lib
- include gdi32.inc
- includelib gdi32.lib;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ;数据变量
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- .data?
- hInstance dd ?
- hWinMain dd ? .const
- szMinCaption db '窗口标题',0
- szWinClass db '窗口类名',0
- szMBCaption db '错误提示',0
- szMBCont1 db '获取模块句柄失败!',0
- szWndCont db '这是我写的第一个窗口,请参观一下,呵呵。。。',0
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ;窗口过程
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- local @stPs:PAINTSTRUCT
- local @stRect:RECT
- local @hDc:HDC
-
- mov eax,uMsg
-
- .if eax == WM_PAINT
- invoke BeginPaint,hWnd,addr @stPs
- mov @hDc,eax
-
- invoke GetClientRect,hWnd,addr @stRect
- invoke DrawText,@hDc,addr szWndCont,-1,\
- addr @stRect,\
- DT_SINGLELINE or DT_CENTER or DT_VCENTER
-
- invoke EndPaint,hWnd,addr @stPs
- ;**********************************************************************
- .elseif eax == WM_CLOSE ;关闭窗口
- invoke DestroyWindow,hWinMain
- invoke PostQuitMessage,NULL
- ;**********************************************************************
- .else
- invoke DefWindowProc,hWnd,uMsg,wParam,lParam
- ret
- .endif
- _ProcWinMain endp
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ;主函数,注册窗口,创建窗口,显示窗口,更新窗口,消息循环等
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- _WinMain proc
- local @stWndClass:WNDCLASSEX
- local @stMsg:MSG
-
-
- ;获取模块句柄
- invoke GetModuleHandle,NULL
- .if eax
- mov hInstance,eax
- .else
- invoke MessageBox,NULL,offset szMBCont1,offset szMBCaption,MB_OK
- .endif
-
- invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
- xor eax,eax
-
- ;**************************************************************************
- ;注册窗口类
- ;**************************************************************************
- invoke LoadIcon,hInstance,IDI_APPLICATION
- mov @stWndClass.hIcon,eax
-
- xor eax,eax
- invoke LoadCursor,hInstance,IDC_ARROW
- mov @stWndClass.hCursor,eax
-
- push hInstance
- pop @stWndClass.hInstance
- mov @stWndClass.cbSize,sizeof WNDCLASSEX
- mov @stWndClass.style,CS_HREDRAW OR CS_VREDRAW
- mov @stWndClass.lpfnWndProc,offset _ProcWinMain
- mov @stWndClass.hbrBackground,COLOR_WINDOW + 1
- mov @stWndClass.lpszClassName,offset szWinClass
- invoke RegisterClassEx,addr @stWndClass
-
- ;**********************************************************************
- ;建立并显示窗口
- ;**********************************************************************
- invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
- offset szWinClass,offset szMinCaption,\
- WS_OVERLAPPEDWINDOW,\
- 100,100,300,400,\
- NULL,NULL,hInstance,NULL
- mov hWinMain,eax
- invoke ShowWindow,hWinMain,SW_SHOWNORMAL
- invoke UpdateWindow,hWinMain
-
- ;**********************************************************************
- ;消息循环
- ;**********************************************************************
- .while TRUE
- invoke GetMessage,addr @stMsg,NULL,0,0
- .break .if eax == 0
- invoke TranslateMessage,addr @stMsg
- invoke DispatchMessage,addr @stMsg
- .endw
- ret_WinMain endp
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ;入口
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- start:
- call _WinMain
- invoke ExitProcess,NULL
-
- END start
-
复制代码
|
|