建设官方网站企业官网,黑龙江建设网官方,深圳华强北手机市场,泰安口碑好的网站建设基本上的窗口都会有一个菜单,现在就来看看Win32汇编中是如何加载菜单的: 1在工程中添加新的菜单资源 2双击新添加的菜单资源进行编辑 3菜单栏:Make-Compile RC来编译资源文件 4导出资源中的ID号并写到数据段的.const中 5下面是完整的源代码供参考:(工程… 基本上的窗口都会有一个菜单,现在就来看看Win32汇编中是如何加载菜单的: 1在工程中添加新的菜单资源 2双击新添加的菜单资源进行编辑 3菜单栏:Make-Compile RC来编译资源文件 4导出资源中的ID号并写到数据段的.const中 5下面是完整的源代码供参考:(工程下载地址) .386 .model flat,stdcall option casemap:none include windows.inc include kernel32.inc include user32.inc include debug.inc includelib kernel32.lib includelib user32.lib includelib debug.lib .data? hInstance dd ? hWinMain dd ? hMenu dd ? .const szClassName db MyClass,0 szCaption db My Window,0 ;---------------------------------------- IDR_MENU equ 10000 IDM_FILE equ 10001 IDM_OPEN equ 10003 IDM_EXIT equ 10002 IDM_EDIT equ 10004 IDM_COPY equ 10005 .code _WinMain proc LOCAL stWndClass:WNDCLASSEX LOCAL stMsg:MSG ;-------------------------- invoke RtlZeroMemory,addr stWndClass,sizeof stWndClass ;-------------------------- invoke GetModuleHandle,NULL mov hInstance,eax ;-------------------------- push hInstance pop stWndClass.hInstance mov stWndClass.cbSize,sizeof WNDCLASSEX mov stWndClass.style,CS_HREDRAW OR CS_VREDRAW mov stWndClass.lpfnWndProc,offset _ProcWinMain mov stWndClass.hbrBackground,COLOR_WINDOW1 mov stWndClass.lpszClassName,offset szClassName invoke LoadCursor,0,IDC_ARROW mov stWndClass.hCursor,eax ;-------------[Regist Window]------------- invoke RegisterClassEx,addr stWndClass ;------------[Load Menu]------------------ invoke LoadMenu,hInstance,IDR_MENU mov hMenu,eax ;-------------[Create Window]------------- invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,\ offset szCaption,WS_OVERLAPPEDWINDOW,100,100,600,400,\ NULL,hMenu,hInstance,NULL mov hWinMain,eax ;-------------------------- invoke ShowWindow,hWinMain,SW_SHOWNORMAL ;-------------------------- invoke UpdateWindow,hWinMain ;-------------------------- .while TRUE invoke GetMessage,addr stMsg,NULL,0,0 .break .if eax0 invoke TranslateMessage,addr stMsg invoke DispatchMessage,addr stMsg .endw ret _WinMain endp ; _ProcWinMain proc uses ebx esi edi hWnd,uMsg,wParam,lParam mov eax,uMsg .if eaxWM_CREATE .elseif eaxWM_CLOSE invoke DestroyWindow,hWinMain invoke PostQuitMessage,NULL .elseif eaxWM_COMMAND mov eax,wParam .if axIDM_EXIT invoke DestroyWindow,hWinMain invoke PostQuitMessage,NULL .endif .elseif invoke DefWindowProc,hWnd,uMsg,wParam,lParam ret .endif xor eax,eax ret _ProcWinMain endp ; start: call _WinMain invoke ExitProcess,NULL end start 转载于:https://www.cnblogs.com/wbbice/archive/2012/09/03/2668400.html