📄 tooltest44.asm
字号:
title ToolTemplate
.586
.model flat, stdcall
option casemap:none ; Case sensitive
include \MASM32V1\PROGRAMS\AsmEdit\include\Windows.inc
include \MASM32V1\PROGRAMS\AsmEdit\include\user32.inc
include \MASM32V1\PROGRAMS\AsmEdit\include\kernel32.inc
include \MASM32V1\PROGRAMS\AsmEdit\include\gdi32.inc
include \MASM32V1\PROGRAMS\AsmEdit\include\comctl32.inc
include \MASM32V1\PROGRAMS\AsmEdit\include\comdlg32.inc
include \MASM32V1\PROGRAMS\AsmEdit\include\DSPMACRO.asm
includelib \MASM32V1\PROGRAMS\AsmEdit\lib\user32.lib
includelib \MASM32V1\PROGRAMS\AsmEdit\lib\kernel32.lib
includelib \MASM32V1\PROGRAMS\AsmEdit\lib\gdi32.lib
includelib \MASM32V1\PROGRAMS\AsmEdit\lib\comctl32.lib
includelib \MASM32V1\PROGRAMS\AsmEdit\lib\comdlg32.lib
;===================================================
; PROTO, MACRO, and Data section
;===================================================
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
RichEditProc PROTO :DWORD, :DWORD, :DWORD, :DWORD
;Insert between
;++++ Proto & Macros ++++++++++++++++++++++++++++++++++++++++++++++++++
ChgBmpColor PROTO :DWORD
;---------- [Toolbar structure macros] ----------
TBSep MACRO hTool
mov tbb.iBitmap, 0
mov tbb.idCommand, 0
mov tbb.fsState, TBSTATE_ENABLED
mov tbb.fsStyle, TBSTYLE_SEP
INVOKE SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb
ENDM
TBButt MACRO hTool, BmpID, CmdID, State, Style, Text
mov tbb.iBitmap, BmpID ; Button image number
mov tbb.idCommand, CmdID ; Command ID number
mov tbb.fsState, State
mov tbb.fsStyle, Style
mov tbb.dwData, 0
mov tbb.iString, Text
INVOKE SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb
ENDM
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MOVmd MACRO Var1, Var2
push Var2
pop Var1
ENDM
.const
;Insert between
;++++ Constants +++++++++++++++++++++++++++++++++++++++++++++++++++++++
IDM_NEW equ 1001
IDM_OPEN equ 1002
IDM_SAVE equ 1003
IDM_CUT equ 1004
IDM_COPY equ 1005
IDM_PASTE equ 1006
IDM_DELETE equ 1007
IDM_FIND equ 1008
IDM_FINDNEXT equ 1009
IDM_FINDPREV equ 1010
IDM_REPLACE equ 1011
IDM_EXIT equ 1012
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
IDM_SELALL equ 2009
.data
RichEdit db 'RichEdit20A',0
RichEdDLL db 'RICHED20.DLL',0
FontNameCN db 'Courier New',0
PopupMenu db 'PopupMenu',0
FontHeight dd -12
FontW dd 400
StatClass db 'msctls_statusbar32',0
szPart1 db 'Part 1',0
szPart3 db 'Part 3',0
ClassName db 'ToolTemplate',0
AppName db 'ToolTemplate',0
MenuName db 'MainMenu',0
szNull db 0
;Insert between
;++++ .data +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ToolClass db 'ToolbarWindow32',0
FloatTBClass db 'FloatToolbar32',0
TextC01 db 'New',0
TextC02 db 'Open',0
TextC03 db 'Save',0
TextC04 db 'Save All',0
TextC05 db 'Cut',0
TextC06 db 'Copy',0
TextC07 db 'Paste',0
TextC08 db 'Delete',0
TextC09 db 'Undo',0
TextC10 db 'Redo',0
TextC11 db 'Find',0
TextC12 db 'FindN',0
TextC13 db 'FindP',0
TextC14 db 'Rep',0
TextC15 db 'MultiI',0
TextC16 db 'Exit',0
szTextC dd TextC01,TextC02,TextC03,TextC04,TextC05,TextC06,
TextC07,TextC08,TextC09,TextC10,TextC11,TextC12,
TextC13,TextC14,TextC15,TextC16
szSpace db ' ',0
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
szError1 db 'The RICHED20.DLL was not found!',0
.data?
hInst dd ?
CommandLine dd ?
MainExit dd ?
hWnd dd ?
hREdDll dd ?
hREdit dd ?
hSMenu dd ?
lpRichEdit dd ?
hFont dd ?
FontName db 64 dup(?)
hWndStat dd ?
sbParts dd 4 dup(?)
MenuCnt dd ?
;Insert between
;++++ .data? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hWndTool dd ?
hImageList dd ?
LeftOn dd ?
TopOn dd ?
RightOn dd ?
BottomOn dd ?
TBLeft dd ?
TBTop dd ?
TBWth dd ?
TBHgt dd ?
hWndDock dd ?
hWndFloat dd ?
hWndToolF dd ?
Styles dd ?
DockW dd ?
DockH dd ?
ToolW dd ?
ToolH dd ?
FloatLock dd ?
LockOn dd ?
SavID dd ?
szTextA db 32 dup(?)
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;---------- [Structures] ----------
tbi TBBUTTONINFO <>
.code
;===================================================
; Program initialization section
;===================================================
start:
INVOKE GetModuleHandle, NULL
mov hInst, eax
INVOKE GetCommandLine
mov CommandLine, eax
call InitCommonControls
INVOKE LoadLibrary, addr RichEdDLL ; Load the Riched20.dll
mov hREdDll, eax
.if !eax
INVOKE MessageBox, NULL, addr szError1, addr AppName, MB_OK or MB_ICONERROR
jmp NoGo
.endif
INVOKE WinMain, hInst ,NULL, CommandLine, SW_SHOWDEFAULT
mov MainExit, eax
INVOKE FreeLibrary, hREdDll
NoGo:
INVOKE ExitProcess, MainExit
;===================================================
; WinMain procedure
;===================================================
WinMain proc uses ebx hinst:DWORD, hPrevInst, CmdLine, CmdShow
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground, COLOR_BTNFACE+1
mov wc.lpszMenuName, offset MenuName
mov wc.lpszClassName, offset ClassName
INVOKE LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
INVOKE LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
INVOKE RegisterClassEx, addr wc
;Insert between if any
;++++ Float/Dock Class ++++++++++++++++++++++++++++++++++++++++++++++++
or wc.style, CS_DBLCLKS
mov wc.lpfnWndProc, offset FloatWndProc
mov wc.lpszClassName, offset FloatTBClass
mov wc.lpszMenuName, NULL
INVOKE RegisterClassEx, addr wc
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;---------- [Center the window] ----------
INVOKE GetSystemMetrics, SM_CXSCREEN
sub eax, 350
shr eax, 1
push eax
INVOKE GetSystemMetrics, SM_CYSCREEN
sub eax, 300
shr eax, 1
pop ebx
;---------- [Create the Main Window] ----------
INVOKE CreateWindowEx, WS_EX_CLIENTEDGE, addr ClassName,\
addr AppName, WS_OVERLAPPEDWINDOW,\
ebx, eax, 350, 300, NULL, NULL, hInst, NULL
mov hWnd, eax
INVOKE ShowWindow, hWnd, SW_SHOWNORMAL
INVOKE UpdateWindow, hWnd
;---------- [Message loop] ----------
.while TRUE
INVOKE GetMessage, addr msg, NULL, 0, 0
.break .if (!eax)
INVOKE TranslateMessage, addr msg
INVOKE DispatchMessage, addr msg
.endw
mov eax, msg.wParam
ret
WinMain endp
;===================================================
; WinProc procedure
;===================================================
WndProc proc uses ebx hwnd:DWORD, wMsg, wParam, lParam
LOCAL rect:RECT
LOCAL lf:LOGFONT
LOCAL charF:CHARFORMAT2
;Insert between
;++++ Locals ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LOCAL tbb:TBBUTTON
LOCAL tbab:TBADDBITMAP
LOCAL bSize:DWORD, hTbBmp, ID, Cnt, Len, Incr, xPos, yPos, WWth, WHgt
LOCAL SavState:BYTE, SavStyle:BYTE
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
LOCAL szBuff[64]:BYTE
;---------- [Create the Control(s) and one time stuff] ----------
.if wMsg == WM_CREATE
;---------- [Create the status bar window] ----------
INVOKE CreateWindowEx, 0, addr StatClass, 0,\
WS_CHILD or WS_BORDER or WS_VISIBLE or SBS_SIZEGRIP,\
0, 0, 0, 0, hwnd, 0, hInst, 0
.if !eax
;Do message
jmp Ret0
.endif
mov hWndStat, eax
;Insert between
;++++ Toolbar code ++++++++++++++++++++++++++++++++++++++++++++++++++++
;---------- [Create the Toolbar Window] ----------
INVOKE CreateWindowEx, 0, addr ToolClass, 0,\
WS_CHILD or WS_VISIBLE or WS_BORDER or CCS_TOP or \
CCS_NORESIZE or CCS_ADJUSTABLE or TBSTYLE_BUTTON or TBSTYLE_TOOLTIPS or \
TBSTYLE_FLAT,\
0, -2, 1200, 26, hwnd, 0, hInst, 0
mov hWndTool, eax
;---------- [Create the ImageList] ----------
INVOKE ImageList_Create, 16, 16, ILC_COLOR32, 16, 0
mov hImageList, eax
;---------- [Load The Bitmaps] ----------
mov ID, 701 ; Bitmap ID
mov Cnt, 16
.while (Cnt)
INVOKE LoadImage, hInst, ID, IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR
INVOKE ChgBmpColor, eax
mov hTbBmp, eax
INVOKE ImageList_Add, hImageList, hTbBmp, NULL
INVOKE DeleteObject, hTbBmp
inc ID
dec Cnt
.endw
INVOKE SendMessage, hWndTool, TB_BUTTONSTRUCTSIZE, sizeof TBBUTTON, 0
INVOKE SendMessage, hWndTool, TB_SETIMAGELIST, 0, hImageList
;---------- [Size the Bitmap and Button] ----------
mov ecx, 16 ; loword = bitmap Width
mov eax, 16 ; hiword = bitmap Height
shl eax, 16
mov ax, cx
mov bSize, eax
INVOKE SendMessage, hWndTool, TB_SETBITMAPSIZE, 0, bSize
mov eax, 23 ; loword = button Width
mov ecx, 22 ; hiword = button Height
shl ecx, 16
mov cx, ax
INVOKE SendMessage, hWndTool, TB_SETBUTTONSIZE, 0, ecx
;---------- [Create the Toolbar structures] ----------
TBButt hWndTool, 0,IDM_NEW,4,0,0
TBButt hWndTool, 1,IDM_OPEN,4,0,0
TBButt hWndTool, 2,IDM_SAVE,4,0,0
TBSep hWndTool
TBButt hWndTool, 4,IDM_CUT,4,0,0
TBButt hWndTool, 5,IDM_COPY,4,0,0
TBButt hWndTool, 6,IDM_PASTE,4,0,0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -