Thread: Win32 API tooltip control

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    6

    Win32 API tooltip control

    Hi all, I am trying to get a tooltip to work, for some reason it just will not pop up. I have followed the MSDN examples exactly. There is also a full example on FoosYerDoos, which when I compile it without changing any of the code, it still doesn't show them up. I am using VC++ 2008.

    Here is my code
    Code:
     INITCOMMONCONTROLSEX ic;
     ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
     ic.dwICC = ICC_TAB_CLASSES;
     InitCommonControlsEx(&ic);
    
     tooltiphWnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, L"", WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, 10, 10, 10, 10, mainhWnd, NULL, mainhInst, NULL);
    
      SetWindowPos(tooltiphWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
      TOOLINFO ti;
      ti.cbSize = sizeof(TOOLINFO);
      ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
      ti.uId = (UINT_PTR)mainexitButton->GethWnd();
      ti.lpszText = L"This is a button.";
      ti.hwnd = mainhWnd;
    
      SendMessage(tooltiphWnd, TTM_ADDTOOL, 0, (LPARAM)&ti);
      SendMessage(tooltiphWnd, TTM_ACTIVATE, true, NULL);
    It should show up when I hover over my exit button. The weird thing is it doesn't work when I compile the FoosYerDoos example either, which makes me think that maybe I am not including something?

    Any help would be greatly appreciated.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Seems to be an issue with vc2008 as earlier versions and other compilers don't produce the same problem. If the executable has a manifest for 'kiddie control styles' then the tooltip works as expected.

    If you'd like to add the manifest, add the following, including quotes, to project settings -->linker--> Manifest File-->additional dependencies:
    Code:
    "type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'"
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Domain for Win32 API
    By maxorator in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-28-2006, 10:16 AM
  2. Replies: 7
    Last Post: 09-18-2005, 08:11 PM
  3. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 03:26 PM
  4. Win32 API Tutorials?
    By c++_n00b in forum C++ Programming
    Replies: 9
    Last Post: 05-09-2002, 03:51 PM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 02:12 AM