模态对话框中菜单显示问题
本帖最后由 兰陵月 于 2018-6-7 09:03 编辑ASM源文件:
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ******************【程】***【序】***【信】***【息】******************
;------------------------------------------------------------------------
; 程序基本信息
;------------------------------------------------------------------------
; 程序名称:SB.asm
; 程序功能:编写程序演示通用对话框的相关实现
; 编辑软件:Notepad++编码格式:ANSI
; 创建日期:2018.06.05
; 创 建 者: by 鱼C论坛 兰陵月QQ:2186745820
;------------------------------------------------------------------------
; MakeFile 文件
;------------------------------------------------------------------------
;NAME = SB
;OBJS = $(NAME).obj
;LINK_FLAG = /subsystem:windows
;ML_FLAG = /c /coff
;$(NAME).exe: $(OBJS)
; Link $(LINK_FLAG) $(OBJS)
;.asm.obj:
; ml $(ML_FLAG) $<
;clean:
; del *.obj
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【模式定义】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【include 文件定义】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
include comdlg32.inc
includelib comdlg32.lib
; include gdi32.inc
; includelib gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【Equ等值定义】,对应资源代码文件中的define部分
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_MAIN equ 1000h
IDM_MAIN equ 1000h
IDM_OPEN equ 3101h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【数据段】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;------------------------------------------------------------------------
; 可读可写已初始化变量
;------------------------------------------------------------------------
; .data
;------------------------------------------------------------------------
; ×××变量定义区×××
;------------------------------------------------------------------------
; 可读可写未初始化变量
;------------------------------------------------------------------------
.data?
;------------------------------------------------------------------------
hInstance dd ?
;hWinMain dd ?
;------------------------------------------------------------------------
; 可读不可写初始化常量
;------------------------------------------------------------------------
; .const
;------------------------------------------------------------------------
; ×××变量定义区×××
;------------------------------------------------------------------------
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【代码段】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;------------------------------------------------------------------------
; **子程序:×××(第×××行~第×××行)
; **功能:
; **参数:
; **返回值:
; **备注:
;------------------------------------------------------------------------
; **子程序代码
;------------------------------------------------------------------------
; **子程序:_WinMain
; **功能:注册窗口、建立并显示窗口、分配消息
; **参数:无参数
; **返回值:无返回值
; **备注:
;------------------------------------------------------------------------
_ProcDlgMain proc uses ebx edi esi, hWnd, wMsg, wParam, lParam
mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;------------------------------------------------------------------------
; **主程序
;------------------------------------------------------------------------
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
;------------------------------------------------------------------------
; 程序起始点
;------------------------------------------------------------------------
end start
;------------------------------------------------------------------------
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
资源文件:
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <resource.h>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define DLG_MAIN 0x1000
#define IDM_MAIN 0x1000
#define IDM_OPEN 0x3101
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_MAIN DIALOG200, 150, 300, 200
//MENU IDM_MAIN
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "通用对话框演示程序"
FONT 9,"宋体"
{
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDM_MAIN menu discardable
BEGIN
popup "文件(&F)"
BEGIN
menuitem "打开文件(&O)...",IDM_OPEN
END
END
MAKEFILE文件:
NAME = SB
OBJS = $(NAME).obj
RES= $(NAME).res
LINK_FLAG = /subsystem:windows
ML_FLAG = /c /coff
$(NAME).exe: $(OBJS) $(RES)
Link $(LINK_FLAG) $(OBJS) $(RES)
.asm.obj:
ml $(ML_FLAG) [ DISCUZ_CODE_2 ]lt;
.rc.res:
rc [ DISCUZ_CODE_2 ]lt;
clean:
del *.obj
del *.res将《资源文件》中第9行注释后,程序能正常显示如下的界面:
程序的本意是要在这个模态对话框的标题栏下显示一个菜单(这是《琢石成器》第8章的一个程序。)
但是现在《资源文件》的第9行如果不注释掉,虽然可以正常编译完成,但是执行SB.EXE后,一闪退出(或者其他现象,反正就是不显示界面),请各位帮忙检查检查,到底是哪里的问题?为何在对话框定义之后加上菜单就不行??
DLG_MAIN DIALOG200, 150, 300, 200
//MENU IDM_MAIN
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
main.asm(90) : error A2006: undefined symbol : ICO_MAIN
main.asm(90) : error A2114: INVOKE argument type mismatch : argument : 2
NMAKE : fatal error U1077: 'ml' : return code '0x1'
Stop. 本帖最后由 兰陵月 于 2018-6-7 09:06 编辑
人造人 发表于 2018-6-6 18:10
程序已经修改,开始是拷贝错了,我把图标ICO_MAIN这个去掉了。
其他情况未发生变化,现在存在的问题还是一楼提出的情况一样~~{:5_104:}
有些注释我没去修改,不管它。 数字太大了 ^_^
main.asm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; ******************【程】***【序】***【信】***【息】******************
;------------------------------------------------------------------------
; 程序基本信息
;------------------------------------------------------------------------
; 程序名称:SB.asm
; 程序功能:编写程序演示通用对话框的相关实现
; 编辑软件:Notepad++编码格式:ANSI
; 创建日期:2018.06.05
; 创 建 者: by 鱼C论坛 兰陵月QQ:2186745820
;------------------------------------------------------------------------
; MakeFile 文件
;------------------------------------------------------------------------
;NAME = SB
;OBJS = $(NAME).obj
;LINK_FLAG = /subsystem:windows
;ML_FLAG = /c /coff
;$(NAME).exe: $(OBJS)
; Link $(LINK_FLAG) $(OBJS)
;.asm.obj:
; ml $(ML_FLAG) $<
;clean:
; del *.obj
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【模式定义】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【include 文件定义】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
include comdlg32.inc
includelib comdlg32.lib
; include gdi32.inc
; includelib gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【Equ等值定义】,对应资源代码文件中的define部分
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;DLG_MAIN equ 1000h
;IDM_MAIN equ 1000h
DLG_MAIN equ 100
IDM_MAIN equ 100
IDM_OPEN equ 3101h
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【数据段】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;------------------------------------------------------------------------
; 可读可写已初始化变量
;------------------------------------------------------------------------
; .data
;------------------------------------------------------------------------
; ×××变量定义区×××
;------------------------------------------------------------------------
; 可读可写未初始化变量
;------------------------------------------------------------------------
.data?
;------------------------------------------------------------------------
hInstance dd ?
;hWinMain dd ?
;------------------------------------------------------------------------
; 可读不可写初始化常量
;------------------------------------------------------------------------
; .const
;------------------------------------------------------------------------
; ×××变量定义区×××
;------------------------------------------------------------------------
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 【代码段】
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;------------------------------------------------------------------------
; **子程序:×××(第×××行~第×××行)
; **功能:
; **参数:
; **返回值:
; **备注:
;------------------------------------------------------------------------
; **子程序代码
;------------------------------------------------------------------------
; **子程序:_WinMain
; **功能:注册窗口、建立并显示窗口、分配消息
; **参数:无参数
; **返回值:无返回值
; **备注:
;------------------------------------------------------------------------
_ProcDlgMain proc uses ebx edi esi, hWnd, wMsg, wParam, lParam
mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;------------------------------------------------------------------------
; **主程序
;------------------------------------------------------------------------
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
;------------------------------------------------------------------------
; 程序起始点
;------------------------------------------------------------------------
end start
;------------------------------------------------------------------------
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
main.rc
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <resource.h>
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//#define DLG_MAIN 0x1000
//#define IDM_MAIN 0x1000
#define DLG_MAIN 100
#define IDM_MAIN 100
#define IDM_OPEN 0x3101
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_MAIN DIALOG200, 150, 300, 200
MENU IDM_MAIN
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "通用对话框演示程序"
FONT 9,"宋体"
{
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDM_MAIN menu discardable
BEGIN
popup "文件(&F)"
BEGIN
menuitem "打开文件(&O)...",IDM_OPEN
END
END
Makefile
NAME = main
OBJS = $(NAME).obj
RES= $(NAME).res
LINK_FLAG = /subsystem:windows
ML_FLAG = /c /coff
$(NAME).exe: $(OBJS) $(RES)
Link $(LINK_FLAG) $(OBJS) $(RES)
.asm.obj:
ml $(ML_FLAG) $<
.rc.res:
rc $<
clean:
del *.obj
del *.res
人造人 发表于 2018-6-7 14:33
数字太大了 ^_^
问题解决,爽歪歪,先确定最佳答案!
我再找些资料来看看,哪个地方有这么个规定数字不能太大,晕死! 人造人 发表于 2018-6-7 14:33
数字太大了 ^_^
多谢了,兄弟。 兰陵月 发表于 2018-6-8 10:16
多谢了,兄弟。
^_^
页:
[1]