📄 009.txt
字号:
.data?
hInstance dd ?
hWinMain dd ?
hWinStatus dd ?
hWinEdit dd ?
lpsz1 dd ?
lpsz2 dd ?
.const
szClass db ~EDIT~,0
szFormat0 db ~%02d:%02d:%02d~,0
szFormat1 db ~字节数:%d~,0
sz1 db ~插入~,0
sz2 db ~改写~,0
dwStatusWidth dd 60,140,172,-1
dwMenuHelp dd 0,IDM_MENUHELP,0,0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Resize proc
local @stRect:RECT,@stRect1:RECT
invoke MoveWindow,hWinStatus,0,0,0,0,TRUE
invoke GetWindowRect,hWinStatus,addr @stRect
invoke GetClientRect,hWinMain,addr @stRect1
mov ecx,@stRect1.right
sub ecx,@stRect1.left
mov eax,@stRect1.bottom
sub eax,@stRect1.top
sub eax,@stRect.bottom
add eax,@stRect.top
invoke MoveWindow,hWinEdit,0,0,ecx,eax,TRUE
ret
_Resize endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
local @szBuffer[128]:byte
local @stST:SYSTEMTIME
local @stPoint:POINT,@stRect:RECT
mov eax,wMsg
;********************************************************************
.if eax == WM_TIMER
invoke GetLocalTime,addr @stST
movzx eax,@stST.wHour
movzx ebx,@stST.wMinute
movzx ecx,@stST.wSecond
invoke wsprintf,addr @szBuffer,addr szFormat0,\
eax,ebx,ecx
invoke SendMessage,hWinStatus,SB_SETTEXT,\
0,addr @szBuffer
;********************************************************************
.elseif eax == WM_CLOSE
invoke KillTimer,hWnd,1
invoke EndDialog,hWnd,NULL
;********************************************************************
.elseif eax == WM_INITDIALOG
mov eax,hWnd
mov hWinMain,eax
invoke CreateStatusWindow,WS_CHILD OR WS_VISIBLE OR \
SBS_SIZEGRIP,NULL,hWinMain,ID_STATUSBAR
mov hWinStatus,eax
invoke SendMessage,hWinStatus,SB_SETPARTS,\
4,offset dwStatusWidth
mov lpsz1,offset sz1
mov lpsz2,offset sz2
invoke SendMessage,hWinStatus,SB_SETTEXT,2,lpsz1
invoke CreateWindowEx,WS_EX_CLIENTEDGE,\
addr szClass,NULL,WS_CHILD or WS_VISIBLE or\
ES_MULTILINE or ES_WANTRETURN or WS_VSCROLL or\
ES_AUTOHSCROLL,\
0,0,0,0,hWnd,ID_EDIT,hInstance,NULL
9.2 使用状态栏(2)
mov hWinEdit,eax
call _Resize
invoke SetTimer,hWnd,1,300,NULL
;********************************************************************
.elseif eax == WM_COMMAND
mov eax,wParam
.if ax == IDM_EXIT
invoke EndDialog,hWnd,NULL
.elseif ax == ID_EDIT
invoke GetWindowTextLength,hWinEdit
invoke wsprintf,addr @szBuffer,\
addr szFormat1,eax
invoke SendMessage,hWinStatus,SB_SETTEXT,\
1,addr @szBuffer
.endif
;********************************************************************
.elseif eax == WM_MENUSELECT
invoke MenuHelp,WM_MENUSELECT,wParam,lParam,\
lParam,hInstance,hWinStatus,offset dwMenuHelp
.elseif eax == WM_SIZE
call _Resize
;********************************************************************
; 检测用户在第3栏的按鼠标动作并将文字在“插入”和“改写”之间切换
;********************************************************************
.elseif eax == WM_NOTIFY
.if wParam == ID_STATUSBAR
mov eax,lParam
mov eax,[eax + NMHDR.code]
.if eax == NM_CLICK
;********************************************************************
invoke GetCursorPos,addr @stPoint
invoke GetWindowRect,hWinStatus,addr @stRect
mov eax,@stRect.left
mov ecx,eax
add eax,140
add ecx,172
.if (@stPoint.x >= eax) && (@stPoint.x <= ecx)
mov eax,lpsz1
xchg eax,lpsz2
mov lpsz1,eax
invoke SendMessage,hWinStatus,SB_SETTEXT,2,lpsz1
.endif
;********************************************************************
.endif
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke InitCommonControls
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,\
NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
资源脚本文件StatusBar.rc的内容如下:
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#define ICO_MAIN 1000
#define DLG_MAIN 1000
#define IDM_MAIN 1000
#define IDM_OPEN 1101
#define IDM_SAVE AS 1102
#define IDM_PAGESETUP 1103
#define IDM_EXIT 1104
#define IDM_FIND 1201
#define IDM_REPLACE 1202
#define IDM_SELFONT 1203
#define IDM_SELCOLOR 1204
#define IDM_MENUHELP 1300
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN ICON "Main.ico"
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DLG_MAIN DIALOG 150, 180, 250, 130
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
menuitem "文件另存为(&C)...",IDM_SAVEAS
menuitem separator
menuitem "页面设置(&P)...",IDM_PAGESETUP
menuitem separator
menuitem "退出(&X)",IDM_EXIT
END
popup "查看(&V)"
BEGIN
menuitem "查找字符串(&S)...",IDM_FIND
menuitem "替换字符串(&R)...",IDM_REPLACE
menuitem separator
menuitem "选择字体(&F)...",IDM_SELFONT
menuitem "选择颜色(&B)...",IDM_SELCOLOR
END
END
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
stringtable discardable
BEGIN
IDM_MENUHELP "包含文件操作的命令"
IDM_MENUHELP+1 "包含操作视图的命令"
IDM_OPEN "打开需要编辑的文件"
IDM_SAVEAS "以另外一个文件名保存文件"
IDM_PAGESETUP "选择打印机以及设置页边距、纸张大小等打印参数"
IDM_EXIT "退出本程序"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -