![]() |
#2
诸葛修勤2011-08-13 17:31
![]() ;MASMPlus 代码模板 - 普通的 Windows 程序代码 .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 ICO_MAIN equ 1000 .data? hInstance dd ? hWin1 dd ? hWin2 dd ? .const szText db 'yu xun feng yi ding ke yi zuo dao geng hao', 0 szClassName1 db 'the first name', 0 szClassName2 db 'the second name', 0 szClassCaption db 'title name...', 0 .code ProcTimer proc _hWnd, _uMsg, _wParam, _lParam local @hDc1, @hDc2 local @stRect:RECT invoke GetDC, hWin1 mov @hDc1, eax invoke GetDC, hWin2 mov @hDc2, eax invoke GetClientRect, hWin1, addr @stRect invoke BitBlt, @hDc2, 0, 0, @stRect.right, @stRect.bottom,\ @hDc1, 0, 0, SRCCOPY invoke ReleaseDC, hWin1, @hDc1 invoke ReleaseDC, hWin2, @hDc2 ret ProcTimer endp WndProc_ proc uses esi edi edx, hWnd, uMsg, wParam, lParam local @stPs:PAINTSTRUCT local @stRect:RECT local @hDc mov eax, uMsg mov ecx, hWnd .if eax == WM_CLOSE invoke PostQuitMessage, NULL invoke DestroyWindow, hWnd .elseif eax == WM_PAINT && ecx == hWin1 invoke BeginPaint, hWnd, addr @stPs mov @hDc, eax invoke GetClientRect, hWnd, addr @stRect invoke DrawText, @hDc, addr szText, -1, \ addr @stRect,\ DT_SINGLELINE or DT_CENTER or DT_VCENTER invoke EndPaint, hWnd, addr @stPs .else invoke DefWindowProc, hWnd, uMsg, wParam, lParam ret .endif xor eax, eax ret WndProc_ endp WinMain_ proc local @stWndClass:WNDCLASSEX local @stMsg:MSG local @hTimer invoke GetModuleHandle, NULL mov hInstance, eax invoke RtlZeroMemory, addr @stWndClass, sizeof WNDCLASSEX invoke LoadIcon, hInstance, ICO_MAIN mov @stWndClass.hIcon, eax invoke LoadCursor, hInstance, IDC_ARROW mov @stWndClass.hCursor, eax mov @stWndClass.cbSize, sizeof WNDCLASSEX mov @stWndClass.style, CS_VREDRAW or CS_HREDRAW push hInstance pop @stWndClass.hInstance mov @stWndClass.hbrBackground, COLOR_WINDOW+1 mov @stWndClass.lpfnWndProc, offset WndProc_ mov @stWndClass.lpszClassName, offset szClassName1 invoke RegisterClassEx, addr @stWndClass invoke CreateWindowEx,WS_EX_CLIENTEDGE, offset szClassName1,\ offset szClassCaption, WS_OVERLAPPEDWINDOW,\ 100, 100, 300, 300,\ NULL, NULL, hInstance, NULL mov hWin1, eax invoke ShowWindow, hWin1, SW_SHOWNORMAL invoke UpdateWindow, hWin1 mov @stWndClass.lpszClassName, offset szClassName2 invoke RegisterClassEx, addr @stWndClass invoke CreateWindowEx, WS_EX_CLIENTEDGE, offset szClassName2,\ offset szClassCaption, WS_OVERLAPPEDWINDOW,\ 450, 100, 300, 300,\ NULL, NULL, hInstance, NULL mov hWin2, eax invoke ShowWindow, hWin2, SW_SHOWNORMAL invoke UpdateWindow, hWin1 invoke SetTimer, NULL, NULL, 100, addr ProcTimer mov @hTimer, eax .while TRUE invoke GetMessage, addr @stMsg, 0, 0, 0 .break .if eax == 0 invoke TranslateMessage, addr @stMsg invoke DispatchMessage, addr @stMsg .endw invoke KillTimer, NULL, @hTimer ret WinMain_ endp Begin: invoke WinMain_ invoke ExitProcess, NULL end Begin |

[ 本帖最后由 诸葛修勤 于 2011-8-13 17:31 编辑 ]