invoke LoadMenu, hInstance, IDM_MAIN
有问题问题是 和没有加载之前是一样
;MASMPlus 代码模板 - 普通的 Windows 程序代码 .386 .model flat, stdcall option casemap:none include windows.inc include user32.inc includelib user32.lib include kernel32.inc includelib kernel32.lib IDM_MAIN equ 1000h ;//#define IDM_FILE 2001h// IDM_OPEN equ 2011h IDM_CLOS equ 2012h IDM_SAVE equ 2013h ;//#define IDM_ICO_CUR 2002h IDM_BIG_ICO equ 2101h IDM_SML_ICO equ 2102h IDM_CUR_A equ 2103h IDM_CUR_B equ 2104h .data? hInstance dd ?;实例句柄 hMenu dd ?;菜单句柄 hWnd dd ?;窗口句柄 .const szClassName db 'the first windows!', 0 szCaptionName db 'Icon and Cursor Example', 0 .code ;回调过程 MainProc_ proc uses esi edx ebx, hwnd, umsg, lParam, wParam mov eax, umsg .if eax == WM_CLOSE invoke DestroyWindow, hwnd invoke PostQuitMessage, 0 .else invoke DefWindowProc, hwnd, umsg, lParam, wParam ret .endif xor eax, eax ret MainProc_ endp ;创建窗口 WinMain_ proc local @wndclass:WNDCLASSEX local @msg:MSG invoke GetModuleHandle, NULL mov hInstance, eax invoke LoadMenu, hInstance, IDM_MAIN mov hMenu, eax invoke RtlZeroMemory, addr @wndclass, sizeof WNDCLASSEX mov @wndclass.cbSize, sizeof WNDCLASSEX mov @wndclass.style, CS_HREDRAW or CS_VREDRAW push offset MainProc_ pop @wndclass.lpfnWndProc push hInstance pop @wndclass.hInstance mov @wndclass.hbrBackground, COLOR_WINDOW+1 mov @wndclass.lpszClassName, offset szClassName invoke LoadCursor, hInstance, IDC_ARROW mov @wndclass.hIcon, eax ;设置窗口属性 invoke RegisterClassEx, addr @wndclass invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,\ offset szCaptionName, WS_OVERLAPPEDWINDOW,\ 100, 100, 400, 300,\ NULL, hMenu, hInstance, NULL mov hWnd, eax invoke ShowWindow, hWnd, SW_NORMAL invoke UpdateWindow, hWnd .while TRUE invoke GetMessage, addr @msg, 0, 0, 0 .break .if eax == 0 invoke TranslateMessage, addr @msg invoke DispatchMessage, addr @msg .endw ret WinMain_ endp Begine: invoke WinMain_ invoke ExitProcess, NULL end Begine
#include <resource.h> #define IDM_MAIN 1000h//菜单 //#define IDM_FILE 2001h// #define IDM_OPEN 2011h #define IDM_CLOS 2012h #define IDM_SAVE 2013h //#define IDM_ICO_CUR 2002h #define IDM_BIG_ICO 2101h #define IDM_SML_ICO 2102h #define IDM_CUR_A 2103h #define IDM_CUR_B 2104h IDM_MAIN menu discardable begin popup "文件(&F)" begin menuitem "打开(&Open)", IDM_OPEN menuitem "保存(&Save)", IDM_SAVE menuitem separator menuitem "关闭(&Close)", IDM_CLOS end popup "图标和光标(&I)" begin menuitem "大图标(&G)", IDM_BIG_ICO menuitem "小图标(&M)", IDM_SML_ICO menuitem separator menuitem "光标A(&A)", IDM_CUR_A menuitem "光标B(&B)", IDM_CUR_B end end