win32使用资源编译问题
MASNPlus编译器显示如下错误:
rc.exe /Fo"1.res" "F:\汇编\32位 try\1.rc"
F:\汇编\32位 try\1.rc (57): error RC2104 : undefined keyword or key name: Ox4101
显示未定义,但我在asm文件中定义了IDM_OPEN equ 4101h
在资源文件中有 #define IDM_OPEN Ox4101
为什么有问题?求人解决。
传个代码来看看啊 asm文件
.386
.model flat, stdcall
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 文件定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN equ 1000h ;图标
IDM_MAIN equ 2000h ;菜单
IDA_MAIN equ 2000h ;加速键
IDM_OPEN equ 4101h
IDM_OPTION equ 4102h
IDM_EXIT equ 4103h
IDM_SETFONT equ 4201h
IDM_SETCOLOR equ 4202h
IDM_INACT equ 4203h
IDM_GRAY equ 4204h
IDM_BIG equ 4205h
IDM_SMALL equ 4206h
IDM_LIST equ 4207h
IDM_DETAIL equ 4208h
IDM_TOOLBAR equ 4209h
IDM_TOOLBARTEXTequ 4210h
IDM_INPUTBAR equ 4211h
IDM_STATUSBAR equ 4212h
IDM_HELP equ 4301h
IDM_ABOUT equ 4302h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
hMenu dd ?
hSubMenu dd ?
.const
szClassName db 'Menu Example',0
szCaptionMain db 'Menu',0
szMenuHelp db '帮助主题(&H)',0
szMenuAbout db '关于本程序(&A)...',0
szCaption db '菜单选择',0
szFormat db '您选择了菜单命令:%08x',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_DisplayMenuItem proc _dwCommandID
local @szBuffer:byte
pushad
invoke wsprintf,addr @szBuffer,addr szFormat,_dwCommandID
invoke MessageBox,hWinMain,addr @szBuffer,\
offset szCaption,MB_OK
popad
ret
_DisplayMenuItem endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Quit proc
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
ret
_Quit endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam
local @stPos:POINT
local @hSysMenu
moveax,uMsg
.if eax ==WM_CREATE
invokeGetSubMenu,hMenu,1
mov hSubMenu,eax
;********************************************************************
;在系统菜单中添加菜单项
;********************************************************************
invokeGetSystemMenu,hWnd,FALSE
mov @hSysMenu,eax
invokeAppendMenu,@hSysMenu,MF_SEPARATOR,0,NULL
invokeAppendMenu,@hSysMenu,\
0,IDM_HELP,offset szMenuHelp
invokeAppendMenu,@hSysMenu,\
0,IDM_ABOUT,offset szMenuAbout
;********************************************************************
; 处理菜单及加速键消息
;********************************************************************
.elseifeax ==WM_COMMAND
invoke_DisplayMenuItem,wParam
mov eax,wParam
movzx eax,ax
.if eax == IDM_EXIT
call _Quit
.elseifeax >=IDM_TOOLBAR && eax <= IDM_STATUSBAR
mov ebx,eax
invokeGetMenuState,hMenu,ebx,MF_BYCOMMAND
.if eax == MF_CHECKED
mov eax,MF_UNCHECKED
.else
mov eax,MF_CHECKED
.endif
invokeCheckMenuItem,hMenu,ebx,eax
.elseifeax >=IDM_BIG && eax <= IDM_DETAIL
invokeCheckMenuRadioItem,hMenu,\
IDM_BIG,IDM_DETAIL,eax,MF_BYCOMMAND
.endif
;********************************************************************
; 处理系统菜单消息
;********************************************************************
.elseif eax == WM_SYSCOMMAND
mov eax,wParam
movzxeax,ax
.if eax == IDM_HELP || eax == IDM_ABOUT
invoke_DisplayMenuItem,wParam
.else
invokeDefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
;********************************************************************
; 单击鼠标右键时弹出一个POPUP菜单
;********************************************************************
.elseif eax == WM_RBUTTONDOWN
invokeGetCursorPos,addr @stPos
invokeTrackPopupMenu,hSubMenu,TPM_LEFTALIGN,\
@stPos.x,@stPos.y,NULL,hWnd,NULL
;********************************************************************
.elseif eax ==WM_CLOSE
call _Quit
;********************************************************************
.else
invokeDefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
;********************************************************************
xor eax,eax
ret
_ProcWinMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG
local @hAccelerator
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadMenu,hInstance,IDM_MAIN
mov hMenu,eax
invoke LoadAccelerators,hInstance,IDA_MAIN
mov @hAccelerator,eax
;********************************************************************
; 注册窗口类
;********************************************************************
invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass
invoke LoadIcon,hInstance,ICO_MAIN
mov @stWndClass.hIcon,eax
mov @stWndClass.hIconSm,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 RegisterClassEx,addr @stWndClass
;********************************************************************
; 建立并显示窗口
;********************************************************************
invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
offset szClassName,offset szCaptionMain,\
WS_OVERLAPPEDWINDOW,\
100,100,400,300,\
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 TranslateAccelerator,hWinMain,\
@hAccelerator,addr @stMsg
.if eax == 0
invokeTranslateMessage,addr @stMsg
invokeDispatchMessage,addr @stMsg
.endif
.endw
ret
_WinMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
call _WinMain
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start 郑涛 发表于 2012-4-14 19:55 static/image/common/back.gif
传个代码来看看啊
rc文件
#include <resource.h>
#define ICO_MAIN Ox1000
#define IDM_MAIN Ox2000
#define IDA_MAIN Ox2000
#define IDM_OPEN Ox4101
#define IDM_OPTION Ox4102
#define IDM_EXIT Ox4103
#define IDM_SETFONT Ox4201
#define IDM_SETCOLOR Ox4202
#define IDM_INACT Ox4203
#define IDM_GRAY Ox4204
#define IDM_BIG Ox4205
#define IDM_SMALL Ox4206
#define IDM_LIST Ox4207
#define IDM_DETAIL Ox4208
#define IDM_TOOLBAR Ox4209
#define IDM_TOOLBARTEXT Ox4210
#define IDM_INPUTBAR Ox4211
#define IDM_STATUSBAR Ox4212
#define IDM_HELP Ox4301
#define IDM_ABOUT Ox4302
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAINICON "Main.ico"
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDM_MAIN MENU
{
popup"文件(&F)"
{
MENUITEM "打开文件(&O)...",IDM_OPEN
MENUITEM "关闭文件(&C)...",IDM_OPTION
MENUITEM separator
MENUITEM "退出(&X)",IDM_EXIT
}
popup"查看(&V)"
{
MENUITEM "字体(&F)...\tAlt+F",IDM_SETFONT
MENUITEM "背景色(&B)...\tCtrl+Alt+B",IDM_SETCOLOR
MENUITEM separator
MENUITEM "被禁用的菜单项",IDM_INACT,INACTIVE
MENUITEM "被灰化的菜单项",IDM_GRAY,GRAYED
MENUITEM separator
MENUITEM "大图标(&G)",IDM_BIG
MENUITEM "小图标(&M)",IDM_SMALL
MENUITEM "列表(&L)",IDM_LIST
MENUITEM "详细资料(&D)",IDM_DETAIL
MENUITEM separator
popup "工具栏(&T)"
{
MENUITEM "标准按钮(&S)",IDM_TOOLBAR
MENUITEM "文字标签(&C)",IDM_TOOLBARTEXT
MENUITEM "命令栏(&I)",IDM_INPUTBAR
}
MENUITEM "状态栏(&U)",IDM_STATUSBAR
}
Popup "帮助(&H)" ,HELP
{
MENUITEM "帮助主题(&H)\tF1",IDM_HELP
MENUITEM separator
MENUITEM "关于本程序(&A)...",IDM_ABOUT
}
END
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDA_MAIN accelerators
{
VK_F1, IDM_HELP, VIRTKEY
"B", IDM_SETCOLOR,VIRTKEY,CONTROL,ALT
"F", IDM_SETFONT, VIRTKEY,ALT
} 我也正为该问题纠结 罗老师电子版的书,看看宏替换,0x..... 写成(字母欧X) ox....感觉被忽悠了 学习学习
页:
[1]