描述:
LRESULT CMFToolbar::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
SendMessage(m_hWnd,TB_BUTTONSTRUCTSIZE,sizeof(TBBUTTON),0);
SendMessage(m_hWnd,TB_SETMAXTEXTROWS,4,0L);
TCHAR* pCaption = _T("MEUU");
int iIndex = ::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption);
TCHAR* pCapti />
iIndex =::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption1);
TCHAR* pCapti />
iIndex =::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption2);
TCHAR* pCapti />
iIndex =::SendMessage(m_hWnd, TB_ADDSTRING, 0,(LPARAM)pCaption3);
// load our button's icon and create the image list to house it.
HICON hMotley = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_MOTLEY));
m_hImageList = ImageList_Create(16,16, ILC_COLOR16, 1, 0);
int iImageIndex = ImageList_AddIcon(m_hImageList, hMotley);
DestroyIcon(hMotley);
hMotley = LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDI_MOTLEY));
iImageIndex = ImageList_AddIcon(m_hImageList, hMotley);
DestroyIcon(hMotley);
// Set the toolbar's image
::SendMessage(m_hWnd, TB_SETIMAGELIST, 0, (LPARAM)m_hImageList);
// add the button for the toolbar to the window
TBBUTTON Button;
ZeroMemory((void*)&Button, sizeof(TBBUTTON));
Button.idCommand = IDM_GETQUOTE;
Button.fsState = TBSTATE_ENABLED;
Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
Button.dwData = 0;
Button.iString = 0;
Button.iBitmap = 0;
int num=::SendMessage(m_hWnd, TB_INSERTBUTTON, 1, (LPARAM)&Button);
TBBUTTON Button1;
ZeroMemory((void*)&Button1, sizeof(TBBUTTON));
Button1.idCommand=IDM_GETQUOTE;
Button1.fsState = TBSTATE_ENABLED;
Button1.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
Button1.dwData = 0;
Button1.iString = 2;
Button1.iBitmap = 0;
num=::SendMessage(m_hWnd, TB_INSERTBUTTON,2, (LPARAM)&Button1);
TBBUTTON Button2;
ZeroMemory((void*)&Button2, sizeof(TBBUTTON));
Button2.idCommand=IDM_GETQUOTE;
Button2.fsState = TBSTATE_ENABLED;
Button2.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
Button2.dwData = 0;
Button2.iString = 3;
Button2.iBitmap = 0;
num=::SendMessage(m_hWnd, TB_INSERTBUTTON,3, (LPARAM)&Button2);
// create our EditQuote window and set the font.
RECT rect = {0,0,0,0};
m_EditWnd.Create(m_hWnd, rect, NULL, WS_CHILD|WS_VISIBLE, WS_EX_CLIENTEDGE);
m_EditWnd.SetFont(static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)));
return 0;
}
这段是代码
为什么我只能得到MENU这个按钮
其他的按钮都不能创建
我也在CSDN找了
他们的好像度可以啊
为什么我得不可以呢
谢谢关注
解决方案1:
Button.idCommand = IDM_GETQUOTE; Button1.idCommand=IDM_GETQUOTE; Button2.idCommand=IDM_GETQUOTE;
Button.fsState = TBSTATE_ENABLED;
Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
这些代码都有问题的。
友情路过一下
解决方案3: // add the button for the toolbar to the window
TBBUTTON Button;
ZeroMemory((void*)&Button, sizeof(TBBUTTON));
Button.idCommand = IDM_GETQUOTE;
Button.fsState = TBSTATE_ENABLED;
Button.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
Button.dwData = 0;
Button.iString = 0;
Button.iBitmap = 0;
int num=::SendMessage(m_hWnd, TB_INSERTBUTTON, 1, (LPARAM)&Button);
TBBUTTON Button1;
ZeroMemory((void*)&Button1, sizeof(TBBUTTON));
Button1.idCommand=IDM_GETQUOTE;
Button1.fsState = TBSTATE_ENABLED;
Button1.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
Button1.dwData = 0;
Button1.iString = 2;
Button1.iBitmap = 0;
num=::SendMessage(m_hWnd, TB_INSERTBUTTON,2, (LPARAM)&Button1);
TBBUTTON Button2;
ZeroMemory((void*)&Button2, sizeof(TBBUTTON));
Button2.idCommand=IDM_GETQUOTE;
Button2.fsState = TBSTATE_ENABLED;
Button2.fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
Button2.dwData = 0;
Button2.iString = 3;
Button2.iBitmap = 0;
num=::SendMessage(m_hWnd, TB_INSERTBUTTON,3, (LPARAM)&Button2);
/////////////////
改成如下代码,试试
TBBUTTON tbb[3];
tbb[0].iBitmap = -1;
tbb[0].idCommand = IDM_GETQUOTE;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].dwData = 0;
tbb[0].iString = 0;
&n