📄 vkdbdemo.asm
字号:
; #########################################################################
; This is a very simple demo that shows how easy Vladimir Kim's debugging
; watch windows is to use. The help file for "DbgWin" is available on the
; help menu in MASM32 to show you how to set up and use "dbgwin".
; #########################################################################
; -------------------------------------------------
; Change this equate to 0 to turn debugging off
debug_on equ 1
; -------------------------------------------------
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include vkdbdemo.inc ; local includes for this file
include dbmacros.asm
include errormac.asm
.code
; #########################################################################
start:
invoke InitCommonControls
; ------------------
; set global values
; ------------------
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke LoadIcon,hInstance,500 ; icon ID
mov hIcon, eax
invoke LoadCursor,NULL,IDC_ARROW
mov hCursor, eax
invoke GetSystemMetrics,SM_CXSCREEN
mov sWid, eax
invoke GetSystemMetrics,SM_CYSCREEN
mov sHgt, eax
call Main
invoke ExitProcess,eax
; #########################################################################
Main proc
LOCAL Wwd:DWORD,Wht:DWORD,Wtx:DWORD,Wty:DWORD
STRING szClassName,"VK_Debug_Class"
IF debug_on
; ********************************************************************************
PrintText "This is a demo of the DbgWin Output Window written by Vladimir Kim"
; ********************************************************************************
ENDIF
; --------------------------------------------
; register class name for CreateWindowEx call
; --------------------------------------------
invoke RegisterWinClass,ADDR WndProc,ADDR szClassName,
hIcon,hCursor,COLOR_BTNFACE+1
; -------------------------------------------------
; macro to autoscale window co-ordinates to screen
; percentages and centre window at those sizes.
; -------------------------------------------------
AutoScale 75, 70
invoke CreateWindowEx,WS_EX_LEFT or WS_EX_ACCEPTFILES,
ADDR szClassName,
ADDR szDisplayName,
WS_OVERLAPPEDWINDOW,
Wtx,Wty,Wwd,Wht,
NULL,NULL,
hInstance,NULL
mov hWnd,eax
; ---------------------------
; macros for unchanging code
; ---------------------------
DisplayMenu hWnd,600
DisplayWindow hWnd,SW_SHOWNORMAL
call MsgLoop
ret
Main endp
; #########################################################################
RegisterWinClass proc lpWndProc:DWORD, lpClassName:DWORD,
Icon:DWORD, Cursor:DWORD, bColor:DWORD
LOCAL wc:WNDCLASSEX
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_BYTEALIGNCLIENT or \
CS_BYTEALIGNWINDOW
m2m wc.lpfnWndProc, lpWndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
m2m wc.hInstance, hInstance
m2m wc.hbrBackground, bColor
mov wc.lpszMenuName, NULL
m2m wc.lpszClassName, lpClassName
m2m wc.hIcon, Icon
m2m wc.hCursor, Cursor
m2m wc.hIconSm, Icon
invoke RegisterClassEx, ADDR wc
ret
RegisterWinClass endp
; ########################################################################
MsgLoop proc
; ------------------------------------------
; The following 4 equates are available for
; processing messages directly in the loop.
; m_hWnd - m_Msg - m_wParam - m_lParam
; ------------------------------------------
LOCAL msg:MSG
StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:
mov eax, msg.wParam
ret
MsgLoop endp
; #########################################################################
WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD
LOCAL var :DWORD
LOCAL caW :DWORD
LOCAL caH :DWORD
LOCAL Rct :RECT
LOCAL buffer1[128]:BYTE ; these are two spare buffers
LOCAL buffer2[128]:BYTE ; for text manipulation etc..
LOCAL szDropFileName[260]:BYTE
.if uMsg == WM_COMMAND
;======== toolbar commands ========
; *****************************************************
.if wParam == 50
IF debug_on
PrintText "Application Main Window Handle"
PrintDword hWnd
ELSE
invoke MessageBox,hWin,SADD("WM_COMMAND ID 50"),
ADDR szDisplayName,MB_OK
ENDIF
.elseif wParam == 51
IF debug_on
PrintText "Application Instance handle"
PrintDword hInstance
ELSE
invoke MessageBox,hWin,SADD("WM_COMMAND ID 51"),
ADDR szDisplayName,MB_OK
ENDIF
.elseif wParam == 52
IF debug_on
PrintText "Tick count since Windows Startup"
invoke GetTickCount
PrintDword eax
ELSE
invoke MessageBox,hWin,SADD("WM_COMMAND ID 52"),
ADDR szDisplayName,MB_OK
ENDIF
; *****************************************************
.endif
;======== menu commands ========
.if wParam == 1001
; --------------------------------------
; szFileName is defined in Filedlgs.asm
; --------------------------------------
mov szFileName[0],0 ; set 1st byte to zero
invoke GetFileName,hWin,SADD("Open A File"),
SADD("All files",0,"*.*",0)
cmp szFileName[0],0 ; zero if cancel pressed in dlgbox
je @F
; ---------------------------------
; perform your file open code here
; ---------------------------------
invoke MessageBox,hWin,ADDR szFileName,ADDR szDisplayName,MB_OK
@@:
.elseif wParam == 1002
; --------------------------------------
; szFileName is defined in Filedlgs.asm
; --------------------------------------
mov szFileName[0],0 ; set 1st byte to zero
invoke SaveFileName,hWin,SADD("Save File As ..."),
SADD("All files",0,"*.*",0,0)
cmp szFileName[0],0 ; zero if cancel pressed in dlgbox
je @F
; ---------------------------------
; perform your file save code here
; ---------------------------------
invoke MessageBox,hWin,ADDR szFileName,ADDR szDisplayName,MB_OK
@@:
.endif
.if wParam == 1010
invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL
.elseif wParam == 1900
ShellAboutBox hWin,hIcon,\
"About VKdb Demo#Windows Debugging Application",\
"VK Debug Demo",13,10,"Copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -