MASM写的第一个Win32 窗口程序

来源:互联网 发布:android php 编辑:程序博客网 时间:2024/05/16 12:02
.386.modelflat,stdcalloption casemap:none;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>;include ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>include windows.incinclude user32.incincludelib user32.libinclude kernel32.incincludelib kernel32.libincludegdi32.incincludelib gdi32.lib.data?hInstancedd?hMainWindd?.constszMyClassdb"MyClass",0szCaptiondb"First Window", 0szTextdb"Hello, world", 0.code;窗口过程函数_ProcMainWinprocuses ebx edi esi, hWnd, uMsg, wParam, lParamLOCAL @hdc:HDCLOCAL @ps:PAINTSTRUCTLOCAL @szRect:RECTmov eax, uMsg.if eax == WM_PAINTinvoke BeginPaint,hWnd, addr @psmov @hdc, eaxinvoke GetClientRect,hWnd, addr @szRectinvoke DrawText,@hdc, offset szText,-1,addr @szRect, DT_SINGLELINE or DT_CENTER or DT_VCENTERinvoke EndPaint,hWnd, addr @ps.elseifeax == WM_CLOSE;如果消息为WM_CLOSE,则销毁窗口,并Post WM_QUIT 到消息循环序列invoke DestroyWindow,[hMainWin];invoke PostQuitMessage,NULL.elseinvoke DefWindowProc,hWnd,uMsg,wParam,lParamret.endifxor eax,eaxret_ProcMainWin endp_MainWinprocLOCAL @wcex:WNDCLASSEXLOCAL @stMsg:MSG;获取窗口句柄invoke GetModuleHandle,NULLmov [hInstance], eaxinvoke RtlZeroMemory,addr @wcex, sizeof @wcex;初始化WNDCLASSEXmov @wcex.cbSize, sizeof(WNDCLASSEX)mov @wcex.style, CS_HREDRAW or CS_VREDRAW;mov @wcex.lpfnWndProc, offset _ProcMainWinmov @wcex.cbClsExtra,0;mov @wcex.cbWndExtra,0;mov eax, [hInstance]mov @wcex.hInstance,eax;invoke LoadIcon,NULL, IDI_WINLOGOmov @wcex.hIcon,eaxinvoke LoadCursor,NULL,IDC_ARROWmov @wcex.hCursor,eaxmov @wcex.hbrBackground,COLOR_WINDOW+1mov @wcex.lpszMenuName, 0mov @wcex.lpszClassName,offset szMyClass;注册窗口类invoke RegisterClassEx,addr @wcex;创建窗口invoke CreateWindowEx,WS_EX_CLIENTEDGE, offset szMyClass, offset szCaption, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,\0,CW_USEDEFAULT, 0, NULL, NULL, [hInstance], NULLmov [hMainWin], eaxinvoke ShowWindow,[hMainWin], SW_SHOWNORMALinvoke UpdateWindow,[hMainWin];进入消息循环.whileTRUEinvoke GetMessage,addr @stMsg, NULL, 0, 0.if eax == 0;如果获取的消息是WM_QUIT,那么EAX位0,则推出消息循环.break.endifinvoke TranslateMessage,addr @stMsginvoke DispatchMessage,addr @stMsg.endwmov eax, @stMsg.wParamret_MainWin endpstart:call_MainWininvokeExitProcess,NULLend start


	
				
		
原创粉丝点击