Thread: Toolbar Tooltips not displaying

  1. #1
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972

    Toolbar Tooltips not displaying

    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
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I still haven't solved this, but I did find out that no matter what I do, the parent window never receives a TTN_GETDISPINFO message (and it should receive one shouldn't it?) It does, however receive messages (such as TBN_HOTITEMCHANGE) from the toolbar.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I finally traced my error back all the way to my windows message loop. Just one part of a line cause all my problems I had:
    Code:
     while(GetMessage(&msg, m_hwnd, 0, 0) > 0)
    	{
    		if (!TranslateMDISysAccel(m_hwndMDIClient, &msg))
    		{
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    	}
    Instead of:
    Code:
     while(GetMessage(&msg, 0, 0, 0) > 0)
    	{
    		if (!TranslateMDISysAccel(m_hwndMDIClient, &msg))
    		{
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    	}
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. toolbar button question
    By supernater in forum Windows Programming
    Replies: 1
    Last Post: 05-25-2009, 08:24 PM
  2. Toolbar color
    By mrafcho001 in forum Windows Programming
    Replies: 2
    Last Post: 04-17-2006, 10:55 AM
  3. Dockable Toolbar (Like taskbar or office toolbar)
    By om3ga in forum Windows Programming
    Replies: 2
    Last Post: 11-20-2005, 03:09 AM
  4. Wild toolbar effect in MFC
    By Guardian in forum Windows Programming
    Replies: 0
    Last Post: 05-15-2002, 05:12 PM
  5. unable to see any tooltips in toolbar
    By jeena in forum Windows Programming
    Replies: 5
    Last Post: 11-21-2001, 07:37 AM