WIN32汇编,关于图标资源那一章的问题
#include <resource.h>
#define IDM_MAIN 0x0001
#define ICO_MAIN 0x0002
#define IDA_MAIN 0x0001
#define IDM_OPTION 0x0003
#define IDM_EXIT 0x0004
#define IDM_SETFONT 0x0005
#define IDM_SETCOLOR 0x0006
#define IDM_BIG 0x0007
#define IDM_SMALL 0x0008
#define ICO_BIG 0x1000
#define ICO_SMALL 0x1001
#define CUR_2 0x1000
#define IDM_CUR1 0x2203
#define IDM_CUR2 0x2204
#define IDM_HELP 0x2205
#define IDM_ABOUT 0x2206
ICO_BIG ICON "Big.ico"
ICO_SMALL ICON "Small.ico"
CUR_2 CURSOR "2.Cur"
IDM_MAIN menu discardable
BEGIN
popup "文件(&F)..."
BEGIN
menuitem "打开文件(&O)..." IDM_OPTION
menuitem separator
menuitem "退出(&P)..." IDM_EXIT
END
popup "设置(&P)..."
BEGIN
menuitem "设置字体" IDM_SETFONT
menuitem "固定光标" IDM_CUR2
menuitem "动态光标" IDM_CUR1
menuitem separator
menuitem "大图标" IDM_BIG
menuitem "小图标" IDM_SMALL
END
END
;编写第一个自主完成的窗口程序
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
include gdi32.inc
includelib gdi32.lib
;----------------------------
;开始等值定义,不同于C的#define,用EQU
;-----------------------------
IDM_MAIN equ 0001h
ICO_MAIN equ 0002h
IDA_MAIN equ 0001h
IDM_OPTION equ 0003h
IDM_EXIT equ 0004h
IDM_SETFONT equ 0005h
IDM_SETCOLOR equ 0006h
IDM_BIG equ 0007h
IDM_SMALL equ 0008h
ICO_SMALL equ 1001h
CUR_2 equ 1000h
IDM_CUR1 equ 2203h
IDM_CUR2 equ 2204h
ICO_BIG equ 1000h
IDM_HELP equ 2205h
IDM_ABOUT equ 2206h
.data
szButton db 'Button',0
szButtonText db 'Button',0
.data?
hInstance dd ?
hWinMain dd ?
hMenu dd ?
hSubMenu dd ?
hIcoBig dd ?
hIcoSmall dd ?
hCur1 dd ?
hCur2 dd ?
.const
szClassName db 'Myclass',0
szCaption db '我的窗口',0
szText db '窗口内容',0
szMessageBoxText db '你按下了这个键,此ID命令是:%d',0
szMessageBoxTitle1 db '按键检测',0
szSysmenuAppen db '增加主题...',0
szCursorFile db '1.ani',0
.code
_DisplayMenuItem Proc _dwCommandId
local @szBuffer[256]:byte
pushad
invoke wsprintf,addr @szBuffer,addr szMessageBoxText,_dwCommandId
invoke MessageBox,hWinMain,addr @szBuffer,addr szMessageBoxTitle1,MB_OK
popad
ret
_DisplayMenuItem endp
_Quit Proc
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
ret
_Quit endp
_WndProc Proc uses ebx esi edi hWnd,uMsg,wParam,lParam ;窗口过程
local @stPs:PAINTSTRUCT ;PAINTSTRUCT包含绘制应用程序所有窗口的信息
local @stRect:RECT ;用来存储成对出现的参数,比如某个点的坐标,高度宽度等
local @hDc
local @stPos:POINT
local @hSysMenu
mov eax,uMsg
.if eax== WM_CREATE
invoke LoadIcon,hInstance,ICO_BIG
mov hIcoBig, eax
invoke LoadIcon,hInstance,ICO_SMALL
mov hIcoSmall,eax
invoke LoadCursorFromFile,addr szCursorFile
mov hCur1,eax
invoke LoadCursor,hInstance,CUR_2
mov hCur2,eax
invoke SendMessage,hWnd,WM_COMMAND,IDM_BIG,NULL
invoke SendMessage,hWnd,WM_COMMAND,IDM_SMALL,NULL
invoke GetSubMenu,hMenu,1
mov hSubMenu,eax;取得第一个菜单的的子菜单的句柄,1代表是第一个,比如菜单
;第一个是文件,那么就是取文件这个菜单的弹出式菜单的句柄
;同理,入股第二个是查看,那么将1改成2,就是取查看这个菜单
;的弹出式菜单的句柄
;-----------------
;在系统菜单中增加菜单项
;-----------------
invoke GetSystemMenu,hWnd,FALSE ;如果参数为TRUE,则将原窗口菜单回复为default,原
;窗口菜单会销毁,用FALSE表示一个窗口菜单的copy,
;并且返回值就是这个copy的句柄,可以进行修改
mov @hSysMenu,eax
invoke AppendMenu,@hSysMenu,MF_SEPARATOR,0,NULL