-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtooltip.cpp
29 lines (24 loc) · 925 Bytes
/
tooltip.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "tooltip.h"
#include <commctrl.h>
#include <cassert>
HWND CreateTooltip(HWND Window, const TCHAR* Text, bool Transparent, HINSTANCE Instance)
{
assert(IsWindow(Window));
HWND TTWindow = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
Window, NULL, Instance, NULL);
if(TTWindow)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS | (Transparent ? TTF_TRANSPARENT : 0); // Don't hide the tooltip on mouse over
ti.hwnd = Window;
ti.hinst = Instance;
ti.uId = 0;
ti.lpszText = Text ? const_cast<TCHAR*>(Text) : LPSTR_TEXTCALLBACK;
GetClientRect(Window, &ti.rect);
SendMessage(TTWindow, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&ti));
}
return TTWindow;
}