I have a toolbar with two buttons on which I would like to add tool tips. I have implemented the code off of the MSDN but I cannot get the tool tips to function Can someone have a look at this code for me?
From my resource file:
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_OPEN_TOOLTIP "Open"
IDS_CLOSE_TOOLTIP "Close"
END
#endif
Creating the toolbar
//Tool bar
TBBUTTON tbbToolBarButtons[NUMBEROFTOOLBARBUTTONS]; //Tool bar button structure
TBADDBITMAP tbabToolBarBitmap; //Tool bar add bitmap structure
SendMessage(hButton[IDC_MAIN_TOOLBAR], TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); //Send TB_BUTTONSTRUCTSIZE for backward compatibility
tbabToolBarBitmap.hInst = HINST_COMMCTRL; //Set the handle of the common control
tbabToolBarBitmap.nID = IDB_STD_SMALL_COLOR; //Set the bitmap to be loaded
SendMessage(hButton[IDC_MAIN_TOOLBAR], TB_ADDBITMAP, 0, (LPARAM)&tbabToolBarBitmap); //Load the images
ZeroMemory(tbbToolBarButtons, sizeof(tbbToolBarButtons)); //Zero the tbbToolBarButtonsUTTON structure
tbbToolBarButtons[0].iBitmap = STD_FILEOPEN; //Set the button bitmap
tbbToolBarButtons[0].fsState = TBSTATE_ENABLED; //Set the state
tbbToolBarButtons[0].fsStyle = TBSTYLE_BUTTON; //Set the style
tbbToolBarButtons[0].idCommand = IDM_OPEN; //Set the menu command
tbbToolBarButtons[0].dwData = IDT_OPEN; //Set the button ID
tbbToolBarButtons[1].iBitmap = STD_DELETE ; //Set the button bitmap
tbbToolBarButtons[1].fsState = TBSTATE_INDETERMINATE; //Set the state
tbbToolBarButtons[1].fsStyle = TBSTYLE_BUTTON; //Set the style
tbbToolBarButtons[1].idCommand = IDM_CLOSE; //Set the menu command
tbbToolBarButtons[1].dwData = IDT_CLOSE; //Set the button ID
SendMessage(hButton[IDC_MAIN_TOOLBAR], TB_ADDBUTTONS, sizeof(tbbToolBarButtons)/sizeof(TBBUTTON), (LPARAM)&tbbToolBarButtons); //Load the buttons
Handling the TBN_GETINFOTIP message:
case TBN_GETINFOTIP:
MessageBox(hWnd, "TBN_GETINFOTIP sent", "Message", MB_ICONERROR);
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
// Set the instance of the module that contains the resource.
lpttt->hinst = (HINSTANCE) GetWindowLong(hWnd,GWL_HINSTANCE);
UINT_PTR idButton = lpttt->hdr.idFrom;
switch (idButton)
{
case IDM_OPEN:
MessageBox(hWnd, "Open", "Message", MB_ICONERROR);
lpttt->lpszText = MAKEINTRESOURCE(IDS_OPEN_TOOLTIP);
break;
case IDM_CLOSE:
MessageBox(hWnd, "Close", "Message", MB_ICONERROR);
lpttt->lpszText = MAKEINTRESOURCE(IDS_CLOSE_TOOLTIP);
break;
}
break;
I receive the "TBN_GETINFOTIP sent" message box when I mouse over one of my buttons. However, I never receive the "Open" or "Close" message box. Am I implementing this incorrectly? Thanks for any help you can offer!