TBBUTTON
TBBUTTON
TBBUTTON
TBBUTTON
TBBUTTON
TBBUTTON
TBBUTTON
TBBUTTON
TBBUTTON
NUM_BUTTONS EQU 16
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
; 代码段
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
来源:电子工业出版社 作者:罗云彬 上一页 回书目 下一页
上一页 回书目 下一页
第9章 通用控件
9。3 使用工具栏(2)
de
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_Resize proc
local @stRect:RECT;@stRect1:RECT
invoke SendMessage;hWinToolbar;TB_AUTOSIZE;0;0
invoke GetClientRect;hWinMain;addr @stRect
invoke GetWindowRect;hWinToolbar;addr @stRect1
mov eax;@stRect1。bottom
sub eax;@stRect1。top
mov ecx;@stRect。bottom
sub ecx;eax
invoke MoveWindow;hWinEdit;0;eax;@stRect。right;ecx;TRUE
ret
_Resize endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_ProcWinMain proc uses ebx edi esi hWnd;uMsg;wParam;lParam
local @szBuffer'128':byte
mov eax;uMsg
;********************************************************************
。if eax WM_CLOSE
invoke DestroyWindow;hWinMain
invoke PostQuitMessage;NULL
;********************************************************************
。elseif eax WM_CREATE
mov eax;hWnd
mov hWinMain;eax
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
mov hWinEdit;eax
invoke CreateToolbarEx;hWinMain;WS_VISIBLE or
WS_CHILD or TBSTYLE_FLAT or TBSTYLE_TOOLTIPS or
CCS_ADJUSTABLE;ID_TOOLBAR;0;HINST_MCTRL;
IDB_STD_SMALL_COLOR;offset stToolbar;
NUM_BUTTONS;0;0;0;0;sizeof TBBUTTON
Mov hWinToolbar;eax
Call _Resize
;********************************************************************
。elseif eax WM_MAND
mov eax;wParam
。if ax IDM_EXIT
invoke EndDialog;hWnd;NULL
。elseif ax != ID_EDIT
invoke wsprintf;addr @szBuffer;
addr szFormat;wParam
invoke MessageBox;hWnd;addr @szBuffer;
addr szCaption;
MB_OK or MB_ICONINFORMATION
。endif
;********************************************************************
。elseif eax WM_SIZE
call _Resize
;********************************************************************
; 处理用户定制工具栏消息
;********************************************************************
。elseif eax WM_NOTIFY
mov ebx;lParam
;********************************************************************
; 因为印刷宽度,请注意缩进格式!
;********************************************************************
。if 'ebx + NMHDRde' TTN_NEEDTEXT
assume ebx:ptr TOOLTIPTEXT
mov eax;'ebx'。hdr。idFrom
mov 'ebx'。lpszText;eax
push hInstance
pop 'ebx'。hinst
assume ebx:nothing
。elseif ('ebx + NMHDRde' TBN_QUERYINSERT) ||
('ebx + NMHDRde' TBN_QUERYDELETE)
mov eax;TRUE
ret
。elseif 'ebx + NMHDRde' TBN_GETBUTTONINFO
assume ebx:ptr TBNOTIFY
mov eax;'ebx'。iItem
。if eax 《 NUM_BUTTONS
mov ecx;sizeof TBBUTTON
mul ecx
add eax;offset stToolbar
invoke RtlMoveMemory;addr 'ebx'。tbButton;eax;sizeof TBBUTTON
invoke LoadString;hInstance;'ebx'。tbButton。idmand;
addr @szBuffer;sizeof @szBuffer
lea eax;@szBuffer
mov 'ebx'。pszText;eax
invoke lstrlen;addr @szBuffer
mov 'ebx'hText;eax
assume ebx:nothing
mov eax;TRUE
ret
。endif
。endif
;********************************************************************
。else
invoke DefWindowProc;hWnd;uMsg;wParam;lParam
ret
。endif
;********************************************************************
xor eax;eax
ret
_ProcWinMain endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_WinMain proc
local @stWndClass:WNDCLASSEX
local @stMsg:MSG
invoke InitmonControls
invoke GetModuleHandle;NULL
mov hInstance;eax
invoke LoadMenu;hInstance;IDM_MAIN
mov hMenu;eax
;********************************************************************
; 注册窗口类
;********************************************************************
invoke RtlZeroMemory;addr @stWndClass;sizeof @stWndClass
invoke LoadIcon;hInstance;ICO_MAIN
mov @stWndClass。hIcon;eax
mov @stWndClass。hIconSm;eax
invoke LoadCursor;0;IDC_ARROW
mov @stWndClass。hCursor;eax
push hInstance
pop @stWndClass。hInstance
mov @stWndClass。cbSize;sizeof WNDCLASSEX
mov @stWndClass。style;CS_HREDRAW or CS_VREDRAW
mov @stWndClass。lpfnWndProc;offset _ProcWinMain
mov @stWndClass。hbrBackground;COLOR_BTNFACE+1
mov @stWndClass。lpszClassName;offset szClassName
invoke RegisterClassEx;addr @stWndClass
来源:电子工业出版社 作者:罗云彬 上一页 回书目 下一页
上一页 回书目 下一页
第9章 通用控件
9。3 使用工具栏(3)
;********************************************************************
; 建立并显示窗口
;********************************************************************
小提示:按 回车 [Enter] 键 返回书目,按 ← 键 返回上一页, 按 → 键 进入下一页。
赞一下
添加书签加入书架