-
-
[求助]是dosmac.inc的错吗?
-
发表于: 2014-1-4 20:19 4123
-
这是老罗的win32asm汇编程序的第六课工具栏和状态栏的使用
今天又遇到了一个难题,望有空的网友能看一看。
以下是源码:
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 是否包括调试代码
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DEBUG = 1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Programmed by 罗云彬, bigluo@telekbird.com.cn
; Website: http://asm.yeah.net
; LuoYunBin's Win32 ASM page (罗云彬的编程乐园)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 版本信息
; 工具栏和状态栏演示程序 Ver 1.0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat, stdcall
option casemap :none ; case sensitive
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 数据
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc
include comdlg32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib comctl32.lib
includelib comdlg32.lib
includelib gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 数据
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDI_MAIN equ 1000 ;icon
IDM_MAIN equ 4000 ;menu
IDM_TOOLBAR equ 4001
IDM_STATUSBAR equ 4002
IDM_EXIT equ 4003
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
hMenu dd ?
hIcon dd ?
hToolbar dd ?
hStatusbar dd ?
szBuffer db 256 dup (?)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
szClassName db "Toolbar Template",0
szCaptionMain db '工具栏和状态栏演示程序 - 罗云彬',0
dwFlag dd F_TOOLBAR or F_STATUSBAR
;********************************************************************
; 标志位定义
F_TOOLBAR equ 00000001b
F_STATUSBAR equ 00000010b
stToolbar TBBUTTON < STD_FILENEW,1,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON <0,0,TBSTATE_ENABLED,TBSTYLE_SEP,2 dup(0),-1>
TBBUTTON < STD_FILEOPEN,2,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON < STD_FILESAVE,3,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON <0,0,TBSTATE_ENABLED,TBSTYLE_SEP,2 dup(0),-1>
TBBUTTON < STD_PRINT,4,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON < STD_PRINTPRE,0,TBSTATE_ENABLED,TBSTYLE_SEP,2 dup(0),-1>
NUM_BUTTONS EQU 7
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
if DEBUG
include Debug.asm
endif
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 程序开始
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
call _WinMain
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 主窗口程序
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain proc
local @stWcMain:WNDCLASSEX
local @stMsg:MSG
;********************************************************************
; 如果已经在运行,则激活已运行的进程
;********************************************************************
invoke FindWindow,offset szClassName,NULL
.if eax != NULL
invoke ShowWindow,eax,SW_SHOWNORMAL
invoke ExitProcess,NULL
.endif
invoke InitCommonControls
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadIcon,hInstance,IDI_MAIN
mov hIcon,eax
invoke LoadMenu,hInstance,IDM_MAIN
mov hMenu,eax
;*************** 注册窗口类 *****************************************
invoke LoadCursor,0,IDC_ARROW
mov @stWcMain.hCursor,eax
mov @stWcMain.cbSize,sizeof WNDCLASSEX
mov @stWcMain.hIconSm,0
mov @stWcMain.style,CS_HREDRAW or CS_VREDRAW
mov @stWcMain.lpfnWndProc,offset WndMainProc
mov @stWcMain.cbClsExtra,0
mov @stWcMain.cbWndExtra,0
mov eax,hInstance
mov @stWcMain.hInstance,eax
mov @stWcMain.hIcon,0
mov @stWcMain.hbrBackground,COLOR_BTNFACE+1
mov @stWcMain.lpszClassName,offset szClassName
mov @stWcMain.lpszMenuName,0
invoke RegisterClassEx,addr @stWcMain
;*************** 建立输出窗口 ***************************************
invoke CreateWindowEx,NULL,\ ;WS_EX_CLIENTEDGE,\
offset szClassName,offset szCaptionMain,\
WS_OVERLAPPEDWINDOW,\ ; OR WS_VSCROLL OR WS_HSCROLL,\
50,50,550,350,\
NULL,hMenu,hInstance,NULL
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
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WndMainProc proc uses ebx edi esi, \
hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
mov eax,uMsg
.if eax == WM_CREATE
mov eax,hWnd
mov hWinMain,eax
call _Init
;********************************************************************
.elseif eax == WM_SIZE
invoke SendMessage,hStatusbar,uMsg,wParam,lParam
invoke SendMessage,hToolbar,uMsg,wParam,lParam
;********************************************************************
.elseif eax == WM_COMMAND
mov eax,wParam
movzx eax,ax
.if eax == IDM_EXIT
call _Quit
.elseif eax == IDM_TOOLBAR
xor dwFlag,F_TOOLBAR
call _ArrangeWindow
.elseif eax == IDM_STATUSBAR
xor dwFlag,F_STATUSBAR
call _ArrangeWindow
.else
_Debug "菜单和工具栏命令","命令ID",eax
.endif
;********************************************************************
.elseif eax == WM_CLOSE
call _Quit
;********************************************************************
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
;********************************************************************
; 注意:WndProc 处理 Windows 消息后,必须在 Eax 中返回 0
; 但是由 DefWindowProc 处理后的返回值不能改变,否则窗口
; 将无法显示!
;********************************************************************
xor eax,eax
ret
WndMainProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 主窗口控制子程序
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Init proc
invoke SendMessage,hWinMain,WM_SETICON,ICON_SMALL,hIcon
invoke CreateToolbarEx,hWinMain,\
WS_VISIBLE or WS_CHILD or TBSTYLE_FLAT or WS_BORDER,\
1,0,HINST_COMMCTRL,IDB_STD_SMALL_COLOR,offset stToolbar,\
NUM_BUTTONS,0,0,0,0,sizeof TBBUTTON
mov hToolbar,eax
invoke CreateStatusWindow,WS_CHILD or WS_VISIBLE,NULL,hWinMain,2
mov hStatusbar,eax
call _ArrangeWindow
ret
_Init endp
;********************************************************************
_Quit proc
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
ret
_Quit endp
;********************************************************************
_ArrangeWindow proc
local @stRect:RECT
local @stRectTemp:RECT
local @dwWidth:DWORD
test dwFlag,F_TOOLBAR
.if ZERO?
invoke ShowWindow,hToolbar,SW_HIDE
invoke CheckMenuItem,hMenu,IDM_TOOLBAR,MF_UNCHECKED
.else
invoke ShowWindow,hToolbar,SW_SHOW
invoke CheckMenuItem,hMenu,IDM_TOOLBAR,MF_CHECKED
.endif
test dwFlag,F_STATUSBAR
.if ZERO?
invoke ShowWindow,hStatusbar,SW_HIDE
invoke CheckMenuItem,hMenu,IDM_STATUSBAR,MF_UNCHECKED
.else
invoke ShowWindow,hStatusbar,SW_SHOW
invoke CheckMenuItem,hMenu,IDM_STATUSBAR,MF_CHECKED
.endif
ret
_ArrangeWindow endp
;********************************************************************
end start
我也不知道怎么会出现这个错误的编译提示!
ExLib\DOSSYM.INC(28) : error A2005: symbol redefinition : TRUE
ExLib\dosmac.INC(12) : error A2005: symbol redefinition : TRUE
ExLib\dosmac.INC(63) : error A2008: syntax error : macro
ExLib\dosmac.INC(65) : error A2061: [ELSE]IF2/.ERR2 not allowed : single-pass assembler
ExLib\dosmac.INC(72) : fatal error A1008: unmatched macro nesting
前两个直接打分号,可是后面的三个没遇到过,求助啊。
今天又遇到了一个难题,望有空的网友能看一看。
以下是源码:
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 是否包括调试代码
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DEBUG = 1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Programmed by 罗云彬, bigluo@telekbird.com.cn
; Website: http://asm.yeah.net
; LuoYunBin's Win32 ASM page (罗云彬的编程乐园)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 版本信息
; 工具栏和状态栏演示程序 Ver 1.0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.386
.model flat, stdcall
option casemap :none ; case sensitive
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include 数据
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
include kernel32.inc
include comctl32.inc
include comdlg32.inc
include gdi32.inc
includelib user32.lib
includelib kernel32.lib
includelib comctl32.lib
includelib comdlg32.lib
includelib gdi32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 数据
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDI_MAIN equ 1000 ;icon
IDM_MAIN equ 4000 ;menu
IDM_TOOLBAR equ 4001
IDM_STATUSBAR equ 4002
IDM_EXIT equ 4003
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
hMenu dd ?
hIcon dd ?
hToolbar dd ?
hStatusbar dd ?
szBuffer db 256 dup (?)
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
szClassName db "Toolbar Template",0
szCaptionMain db '工具栏和状态栏演示程序 - 罗云彬',0
dwFlag dd F_TOOLBAR or F_STATUSBAR
;********************************************************************
; 标志位定义
F_TOOLBAR equ 00000001b
F_STATUSBAR equ 00000010b
stToolbar TBBUTTON < STD_FILENEW,1,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON <0,0,TBSTATE_ENABLED,TBSTYLE_SEP,2 dup(0),-1>
TBBUTTON < STD_FILEOPEN,2,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON < STD_FILESAVE,3,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON <0,0,TBSTATE_ENABLED,TBSTYLE_SEP,2 dup(0),-1>
TBBUTTON < STD_PRINT,4,TBSTATE_ENABLED,TBSTYLE_BUTTON,2 dup(0),-1>
TBBUTTON < STD_PRINTPRE,0,TBSTATE_ENABLED,TBSTYLE_SEP,2 dup(0),-1>
NUM_BUTTONS EQU 7
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
if DEBUG
include Debug.asm
endif
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 程序开始
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
call _WinMain
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 主窗口程序
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_WinMain proc
local @stWcMain:WNDCLASSEX
local @stMsg:MSG
;********************************************************************
; 如果已经在运行,则激活已运行的进程
;********************************************************************
invoke FindWindow,offset szClassName,NULL
.if eax != NULL
invoke ShowWindow,eax,SW_SHOWNORMAL
invoke ExitProcess,NULL
.endif
invoke InitCommonControls
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke LoadIcon,hInstance,IDI_MAIN
mov hIcon,eax
invoke LoadMenu,hInstance,IDM_MAIN
mov hMenu,eax
;*************** 注册窗口类 *****************************************
invoke LoadCursor,0,IDC_ARROW
mov @stWcMain.hCursor,eax
mov @stWcMain.cbSize,sizeof WNDCLASSEX
mov @stWcMain.hIconSm,0
mov @stWcMain.style,CS_HREDRAW or CS_VREDRAW
mov @stWcMain.lpfnWndProc,offset WndMainProc
mov @stWcMain.cbClsExtra,0
mov @stWcMain.cbWndExtra,0
mov eax,hInstance
mov @stWcMain.hInstance,eax
mov @stWcMain.hIcon,0
mov @stWcMain.hbrBackground,COLOR_BTNFACE+1
mov @stWcMain.lpszClassName,offset szClassName
mov @stWcMain.lpszMenuName,0
invoke RegisterClassEx,addr @stWcMain
;*************** 建立输出窗口 ***************************************
invoke CreateWindowEx,NULL,\ ;WS_EX_CLIENTEDGE,\
offset szClassName,offset szCaptionMain,\
WS_OVERLAPPEDWINDOW,\ ; OR WS_VSCROLL OR WS_HSCROLL,\
50,50,550,350,\
NULL,hMenu,hInstance,NULL
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
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
WndMainProc proc uses ebx edi esi, \
hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
mov eax,uMsg
.if eax == WM_CREATE
mov eax,hWnd
mov hWinMain,eax
call _Init
;********************************************************************
.elseif eax == WM_SIZE
invoke SendMessage,hStatusbar,uMsg,wParam,lParam
invoke SendMessage,hToolbar,uMsg,wParam,lParam
;********************************************************************
.elseif eax == WM_COMMAND
mov eax,wParam
movzx eax,ax
.if eax == IDM_EXIT
call _Quit
.elseif eax == IDM_TOOLBAR
xor dwFlag,F_TOOLBAR
call _ArrangeWindow
.elseif eax == IDM_STATUSBAR
xor dwFlag,F_STATUSBAR
call _ArrangeWindow
.else
_Debug "菜单和工具栏命令","命令ID",eax
.endif
;********************************************************************
.elseif eax == WM_CLOSE
call _Quit
;********************************************************************
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
;********************************************************************
; 注意:WndProc 处理 Windows 消息后,必须在 Eax 中返回 0
; 但是由 DefWindowProc 处理后的返回值不能改变,否则窗口
; 将无法显示!
;********************************************************************
xor eax,eax
ret
WndMainProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 主窗口控制子程序
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Init proc
invoke SendMessage,hWinMain,WM_SETICON,ICON_SMALL,hIcon
invoke CreateToolbarEx,hWinMain,\
WS_VISIBLE or WS_CHILD or TBSTYLE_FLAT or WS_BORDER,\
1,0,HINST_COMMCTRL,IDB_STD_SMALL_COLOR,offset stToolbar,\
NUM_BUTTONS,0,0,0,0,sizeof TBBUTTON
mov hToolbar,eax
invoke CreateStatusWindow,WS_CHILD or WS_VISIBLE,NULL,hWinMain,2
mov hStatusbar,eax
call _ArrangeWindow
ret
_Init endp
;********************************************************************
_Quit proc
invoke DestroyWindow,hWinMain
invoke PostQuitMessage,NULL
ret
_Quit endp
;********************************************************************
_ArrangeWindow proc
local @stRect:RECT
local @stRectTemp:RECT
local @dwWidth:DWORD
test dwFlag,F_TOOLBAR
.if ZERO?
invoke ShowWindow,hToolbar,SW_HIDE
invoke CheckMenuItem,hMenu,IDM_TOOLBAR,MF_UNCHECKED
.else
invoke ShowWindow,hToolbar,SW_SHOW
invoke CheckMenuItem,hMenu,IDM_TOOLBAR,MF_CHECKED
.endif
test dwFlag,F_STATUSBAR
.if ZERO?
invoke ShowWindow,hStatusbar,SW_HIDE
invoke CheckMenuItem,hMenu,IDM_STATUSBAR,MF_UNCHECKED
.else
invoke ShowWindow,hStatusbar,SW_SHOW
invoke CheckMenuItem,hMenu,IDM_STATUSBAR,MF_CHECKED
.endif
ret
_ArrangeWindow endp
;********************************************************************
end start
我也不知道怎么会出现这个错误的编译提示!
ExLib\DOSSYM.INC(28) : error A2005: symbol redefinition : TRUE
ExLib\dosmac.INC(12) : error A2005: symbol redefinition : TRUE
ExLib\dosmac.INC(63) : error A2008: syntax error : macro
ExLib\dosmac.INC(65) : error A2061: [ELSE]IF2/.ERR2 not allowed : single-pass assembler
ExLib\dosmac.INC(72) : fatal error A1008: unmatched macro nesting
前两个直接打分号,可是后面的三个没遇到过,求助啊。
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
看原图
赞赏
雪币:
留言: