.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
.data?
hInstance dd ?
nhWnd dd ?
.data
SZClassName db "My Windows"
SZWindowsName db "My First WIN32 Windows"
MAString db "Left Button is Downed"
.code
;窗口回调函数
WinProc Proc uses ebx edi esi,hWnd,Msg,wParam,lParam;错误!在使用寄存器之间不可以有逗号
mov eax,Msg
;处理消息
.if eax == WM_LBUTTONDOWN;左键按下
invoke MessageBox,NULL,MAString,"Tip",MB_OK
.elseif eax == WM_DESTROY;销毁窗口
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,Msg,wParam,lParam;未处理的消息送到默认消息处理
.endif
xor eax,eax
ret
WinProc endp
;主函数
_WinMain Proc
local @Wnd:WNDCLASSEX
local @Msg:MSG
invoke GetModuleHandle,NULL;获取句柄
mov hInstance,eax;获取句柄后返回值保存在eax中。
invoke RtlZeroMemory,addr @Wnd,sizeof @Wnd;初始化结构体全部数值为零
;WNDCLASS结构初始化
invoke LoadCursor,0,IDC_ARROW
mov @Wnd.hCursor,eax
mov @Wnd.style,CS_HREDRAW OR CS_VREDRAW;类型赋值
mov @Wnd.lpfnWndProc,offset WinProc;窗口回调函数的地址
mov @Wnd.cbSize,sizeof WNDCLASS
mov @Wnd.hbrBackground,COLOR_WINDOW+1;窗口的背景
mov @Wnd.lpszClassName,offset SZClassName
push hInstance
pop @Wnd.hInstance
;;;;;;;;;;;;;;;;;;;;;;
invoke RegisterClassEx,addr @Wnd;注册窗口
;创建窗口
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset SZClassName,\
offset SZWindowsName,WS_OVERLAPPEDWINDOW,\
100,100,500,600,NULL,NULL,hInstance,NULL
mov nhWnd,eax
invoke ShowWindow,nhWnd,SW_SHOWNORMAL;显示窗口
invoke UpdateWindow,nhWnd;更新窗口
;消息循环,注意条件语句前面要有点点(.)
.while TRUE
invoke GetMessage,addr @Msg,NULL,0,0
.break .if eax==0
invoke TranslateMessage,addr @Msg
invoke DispatchMessage,addr @Msg
.endw
ret
_WinMain endp
start:
call _WinMain
invoke ExitProcess,NULL
end start
窗口没有显示出来,但是在进程管理器中有这个程序的进程。
我学过C语言,也会用C语言实现简单的窗口设计,可是这是哪里出了问题?
求求大大们帮帮我看看。就是和罗云彬的《琢石成器》书上的差不多啊。只是少处理了几个消息,但是不影响显示啊。