KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to use the native windows tooltip control (pure Win32 API, no MFC stuff). I read the doc, it seems that I have to send a TTM_ADDTOOL message to bond a tool to the tooltip control. Only after that can I send TTM_TRACKACTIVATE & TTM_TRACKPOSITION to show the tooltip. But I want to display the tooltip anywhere I want it to be. For example, when the mouse hovers over a region of my window. This region is not a tool in the eye of Windows, it's just a region in my window. Perhaps I can bond the window to the tooltip control, but, doesn't this mean that I have to bond every window I created to the tooltip control? Is there an easy solution so that I don't have to send TTM_ADDTOOL messages for every window? I actually have written some code, but the tooltip just doesn't appear. Anders' answer solves some questions actually. And after I poke around my code, I make it work. In case someone wants to know how it work: HWND toolTipWnd = ::CreateWindowExW(WS_EX_TOPMOST, TOOLTIPS_CLASSW,0,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, 0,0,appHandle,0); TOOLINFOW ti = {}; ti.cbSize = sizeof(TOOLINFOW); ti.uFlags = TTF_ABSOLUTE | TTF_IDISHWND /* | TTF_TRACK */; // Don't specify TTF_TRACK here. Otherwise the tooltip won't show up. ti.hwnd = toolTipWnd; // By doing this, you don't have to create another window. ti.hinst = NULL; ti.uId = (UINT)toolTipWnd; ti.lpszText = L""; ::SendMessageW(toolTipWnd, TTM_ADDTOOLW, 0, (LPARAM)&ti); ::SendMessageW(toolTipWnd, TTM_SETMAXTIPWIDTH,0, (LPARAM)350); This will create a tooltip window which is not bound to any other window. So when you want to show the tooltip (e.g. in responds to WM_MOUSEHOVER message), call this: TOOLINFOW ti = {}; ti.cbSize = sizeof(TOOLINFOW); ti.hwnd = toolTipWnd; ti.uId = (UINT)toolTipWnd; ti.lpszText = L
Tags (comma-separated)
Save Edits
Cancel