如何给一个ToolBar添加按钮?
如何给一个ToolBar添加按钮?
我一开始以为要自己弄几个button子窗口,并把hWndParent指定为Toolbar就好了,实际上我要照做了,后来才发现原来comctl32自带了TBBUTTON结构和TB_ADDBUTTONS消息,可是我不会加按钮。
hwndtoolbar = CreateWindowEx (0,TEXT("ToolbarWindow32"), TEXT("mytoolbar"),WS_CHILD | WS_VISIBLE | WS_EX_CLIENTEDGE | TBS_TOP | TBS_HORZ | TBSTYLE_FLAT,0,0,700,50,hwnd,(HMENU)1002,((LPCREATESTRUCT)lParam)->hInstance,NULL);
TBBUTTON tbb;
tbb.iBitmap = STD_FILENEW;
tbb.fsState = TBSTATE_ENABLED;
tbb.fsStyle = TBSTYLE_BUTTON;
tbb.dwData = 0; //这是啥?
tbb.iString = 0; //这是啥?
tbb.idCommand = 0; //这是啥?
SendMessage (hwndtoolbar, TB_ADDBUTTONS, 20, (LPARAM)&tbb) ;
问题点数:10、回复次数:5Top
1 楼xmlscript(C++还真是个好东西)回复于 2005-03-31 02:04:32 得分 0
没人看的上,还是没人会呀?Top
2 楼longlago(等待的郁闷)回复于 2005-03-31 03:12:53 得分 9
你问错地方了吧。Top
3 楼heluqing(鉴之小河〖劳累求充实〗)(vcl .net)回复于 2005-03-31 08:31:06 得分 1
右键...add newbuttonTop
4 楼xmlscript(C++还真是个好东西)回复于 2005-04-06 12:43:35 得分 0
哦?真的问错地方了,倒霉!!!不是C/C++版吗?!
我说怎么没人理我呢?!
那把分给你们吧。Top
5 楼lwk_hlj(阿凯(学习oralce中))回复于 2005-04-06 12:45:47 得分 0
The TBBUTTON structure contains information about a button in a toolbar.
typedef struct _TBBUTTON { \\ tbb
int iBitmap;
int idCommand;
BYTE fsState;
BYTE fsStyle;
DWORD dwData;
int iString;
} TBBUTTON, NEAR* PTBBUTTON, FAR* LPTBBUTTON;
typedef const TBBUTTON FAR* LPCTBBUTTON;
Members
iBitmap
Zero-based index of button image.
idCommand
Command identifier associated with the button. This identifier is used in a WM_COMMAND message when the button is chosen. If the fsStyle member is the TBSTYLE_SEP value, this member must be zero.
fsState
Button state flags. This member can be a combination of the values listed in Toolbar Button States.
fsStyle
Button style. This member can be a combination of values listed in Toolbar Button Styles
dwData
Application-defined value.
iString
Zero-based index of button string.
See Also
WM_COMMANDTop




