Win32匯編--加載菜單資源

基本上的窗口都會有一個菜單,現在就來看看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_WINDOW+1 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 eax==0 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 eax==WM_CREATE .elseif eax==WM_CLOSE invoke DestroyWindow,hWinMain invoke PostQuitMessage,NULL .elseif eax==WM_COMMAND mov eax,wParam .if ax==IDM_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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274624.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274624.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274624.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Futura:從納粹主義到月球-甚至更遠

Reading the title of this article, the first thing that will come to mind for some is the funny expression of Buzz Lightyear — the Disney character — when he stretches his arms outwards and utters the famous phrase “To infinity and beyond!” before jump…

如何碎片化時間高效學習前端~

前端技術日新月異,發展迅速,作為一個與時俱進的前端工程師,需要不斷的學習。這里強烈推薦幾個前端開發工程師必備的優質公眾號,希望對你有所幫助。大家可以像我一樣,利用碎片時間閱讀這些公眾號的文章。前端從進階到入…

爬取淘寶定價需要多久時間_如何對設計工作進行定價—停止收??取時間并專注于價值

爬取淘寶定價需要多久時間Pricing creative work is a new concept for most freelancers who are starting their business. We are used to being paid for our time, either by an hourly wage or an annual salary. It makes it simple to quantify how much value we thin…

OEA 框架中集成的 RDLC 報表介紹

之前 OEA 一直用著一個 Delphi 開發的報表,所以兩年來我一直就想在 OEA 中構建一個純 .NET 的報表模塊,但是一想到要開發復雜的報表引擎和設計器就覺得麻煩。所以這事一直拖著。最近開始研究一些成熟的報表引擎,經過對比,還是發現…

昆蟲繁殖_“專為昆蟲而生” –好奇!

昆蟲繁殖重點 (Top highlight)The industry is changing towards a more agile approach and jacks of one trade can go extinct sooner than we think.該 行業正在發生變化 朝著更加靈活的方法和一個貿易的插Kong可以去滅絕快于我們的想法。 I’ve read a quote in a book r…

ECMAScript 2022 正式發布,有哪些新特性?

大家好,我是若川。持續組織了近一年的源碼共讀活動,感興趣的可以 點此加我微信ruochuan12 參與,每周大家一起學習200行左右的源碼,共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。…

字母框如何影響UI內容的理解

What is your earliest memory of reading? Mine’s reading comics. I preferred films over books, I still do, but I seemed to have a fascination for comics. The experience of reading a comic, to me, was somewhere between watching a film and reading a novel, …

Vue2.7 本周發布?支持組合式 API、setup、css v-bind

大家好,我是若川。持續組織了近一年的源碼共讀活動,感興趣的可以 點此加我微信ruochuan12 參與,每周大家一起學習200行左右的源碼,共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。…

linux中用戶忘記root的密碼--ubuntu版本

基于ubuntu操作系統的情況,當用戶忘記root密碼后, 在普通用戶登陸后 輸入sudu su root 之后系統要求輸入當前用戶的密碼,用戶輸入密碼后,就可以進入root的模式了 就可以操作任何任務。轉載于:https://www.cnblogs.com/zhengyn/arc…

馬上7月,誠邀新老朋友參加近5000人的源碼共讀活動!

大家好,我是若川。最近有不少新朋友關注我。誠邀各位新老讀者朋友參加源碼共讀活動。活動介紹可以點擊文末的閱讀原文。https://juejin.cn/post/7079706017579139102很多人關注我的公眾號是因為我寫了一系列源碼文章,想參與源碼共讀活動。雖然現在有近50…

hashmap 從頭到尾_如何從頭到尾設計一個簡單的復古徽標

hashmap 從頭到尾在紙上素描粗糙的概念 (Sketch rough concepts on paper) Start by sketching out a few ideas for your logo on paper. These don’t have to be detailed drawings. Instead, it’s about getting your ideas out quickly. In this early stage, you can ex…

(轉)android技巧01:Preferencescreen中利用intent跳轉activity

原文連接:http://blog.csdn.net/xianming01/article/details/7543464 設置中的Preferencescreen不僅可以作為設置界面顯示,而且還能夠啟動activity,下面主要是對啟動activity的介紹1. Preferencescreen中啟動activity 例如wireless_setting.x…

Vue 2.7 正式發布,代號為 Naruto

大家好,我是若川。持續組織了近一年的源碼共讀活動,感興趣的可以 點此加我微信ruochuan12 參與,每周大家一起學習200行左右的源碼,共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。…

js設置css色相旋轉_色相旋轉顏色方案是否保留了對色盲友好的能力?

js設置css色相旋轉Hue rotation is often an easy way to change the appearance of a plot or figure without the need to create a new colour bar. However, when dealing with colourblindness, it is important to ensure that the spacing between colours is sufficien…

Tyvj 1921 Freda的煩惱

我就不說是CF hot days 原題了,我會告訴你使用Math庫是因為一開始偷懶不想寫Min函數么- 1 Uses math;2 Var n,m,i,t,tt,x,cost,ans,tmp:qword;3 Function min(x,y:qword):qword;4 Begin5 if x>y then exit(y);6 exit(x);7 end;8 Begin9 readln(n,m);10 …

ux設計中的各種地圖_在UX設計中使用阿拉伯語

ux設計中的各種地圖Last year I got to work on an app that was ultimately going to be deployed globally in every market and every language including RTL (Right-to-Left) languages — with a specific focus on Arabic.去年,我開始致力于開發一個應用程序…

如何為前端項目一鍵自動添加eslint和prettier的支持

本文來自讀者那個曾經的少年回來了 寫的源碼共讀35期筆記文章,授權投稿,寫的真好。本文參加了由公眾號若川視野 發起的每周源碼共讀活動,點此加我微信 ruochuan12 了解詳情一起參與。本文屬于源碼共讀第35期 | 為 vite 項目自動添加 eslint 和…

Server.Transfer方法在頁面間傳值

a.aspx頁面代碼: protected void Button5_Click(object sender, EventArgs e){Server.Transfer("b.aspx");}public string name{get{return this.TextBox1.Text;}} b.aspx頁面代碼: private void TheFour(){a newWebContext.Handler as a;//創…

極端原理_為極端而設計

極端原理*You can also read this article in German here.*您也可以 在此處 閱讀 德語文章 。 In this article I’m going to draw on the Design thinking concept of designing for extreme users and I will argue that designing for extreme users can be considered a…

當CV工程師碰到了拷貝粘貼的需求——useClipboard的使用及源碼解析

大家好,我是若川。持續組織了近一年的源碼共讀活動,感興趣的可以 點此加我微信ruochuan12 參與,每周大家一起學習200行左右的源碼,共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系列。…