I created a toolbar, and now I want tooltips to display when the mouse hovers over the buttons. I thought the following code should work:
Code:
m_hTool = CreateWindowEx(0,TOOLBARCLASSNAME, 0, WS_CHILD | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
0,0,0,0,m_hwnd,(HMENU)IDC_MAIN_TOOL,m_hinst,0);
if(!m_hTool)
{
MessageBox(NULL,"Failed to create toolbar!","Error!",MB_OK);
return false;
}
SendMessage(m_hTool, TB_BUTTONSTRUCTSIZE,(WPARAM) sizeof(TBBUTTON), 0);
SendMessage(m_hTool, TB_SETMAXTEXTROWS,0,0);
TBBUTTON tbb[NUM_TOOL_BUTTONS];
ZeroMemory(tbb, sizeof(tbb));
for (int i=0;i<NUM_TOOL_BUTTONS;i++)
{
tbb[i].iBitmap = i;
tbb[i].fsState = TBSTATE_ENABLED;
tbb[i].fsStyle = BTNS_BUTTON;
tbb[i].idCommand = TOOL_BTN_ID[i];
tbb[i].iString = SendMessage(m_hTool, TB_ADDSTRING, 0, (LPARAM) "Text");
}
TBADDBITMAP tb;
tb.hInst = m_hinst;
tb.nID = IDB_BITMAP2;
SendMessage (m_hTool, TB_ADDBITMAP, 2, (LPARAM)&tb);
SendMessage(m_hTool, TB_ADDBUTTONS, (WPARAM)2, (LPARAM) (LPTBBUTTON) &tbb);
SendMessage(m_hTool, TB_AUTOSIZE, 0, 0);
ShowWindow(m_hTool, SW_SHOWNORMAL);
The buttons/bitmaps display fine, but there's no tooltip. If I don't send TB_SETMAXTEXTROWS then the text displays in the button. Hopefullly I'm just doing something stupid again