|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 兰陵月 于 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 DIALOG 200, 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 DIALOG 200, 150, 300, 200
//MENU IDM_MAIN
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
数字太大了 ^_^
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 DIALOG 200, 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
|
|