学习win32汇编出现问题了,大婶们来帮帮小弟一下 啊
.386
.model flat,stdcall
option casemap:none
include windows.inc
include gdi32.inc
includelib gdi32.lib
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
.data?
hWinMain dd ?
.const
szWinName db 'First windows',0
szWinCaption db 'windows',0
szText db '欢迎来到win32汇编程序设计!',0
.code
_ProcWinMain proc uses eax ebx esi edi,hWnd,uMsg,wParam,lParam
local @wndcls:WNDCLASS
local @ps:PAINTSTRUCT
local @hdc
mov eax,uMsg
.if eax == WM_PAINT
invoke BeginPaint,hWnd,addr @ps
mov @hdc,eax
invoke TextOut,@hdc,0,25,addr szText,sizeof szText
invoke EndPaint,@hdc,addr @ps
.elseif eax == WM_CLOSE
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
_ProcWinMain endp
_WinMain proc uses eax ebx esi edi,hInstance,hPrevInstance,lpCmdLine,nCmdShow
local @wndcls:WNDCLASS
local @msg:MSG
mov @wndcls.style,CS_VREDRAW or CS_HREDRAW
mov @wndcls.lpfnWndProc,offset _ProcWinMain
mov @wndcls.cbClsExtra,0
mov @wndcls.cbWndExtra,0
push hInstance
pop @wndcls.hInstance
invoke LoadIcon,NULL,IDI_APPLICATION
mov @wndcls.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov @wndcls.hCursor,eax
mov @wndcls.hbrBackground,COLOR_WINDOW
mov @wndcls.lpszMenuName,NULL
mov @wndcls.lpszClassName,offset szWinName
invoke RegisterClass,addr @wndcls
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr szWinName,addr szWinCaption,WS_OVERLAPPEDWINDOW,\
100,100,300,340,NULL,NULL,hInstance,NULL
mov hWinMain,eax
invoke ShowWindow,hWinMain,SW_SHOWNORMAL
invoke UpdateWindow,hWinMain
.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
代码能生成exe文件,但是为什么运行后明明有对话框在屏幕上,我却不能用鼠标选取它?不过能在任务栏上点击,这个是什么问题?
[解决办法]
_WinMain proc uses eax ebx esi edi,hInstance ... 中将 eax 去掉,否则会进行 eax 的保存和恢复从而导致返回值被破坏而致 windows 误判。