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 30 31
| HWND create_tooltip(HWND hMain, HINSTANCE hInstance, UINT max_tip_width, create_tooltip_t tool_tips[])
{
HWND hTip;
TOOLINFO toolInfo = {0};
int i;
// Create the tooltip window
hTip = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hMain, NULL,
hInstance, NULL);
if (hTip == NULL) {
return (HWND)NULL;
}
// Associate the tooltip to the control
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.hwnd = hMain;
toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
for (i=0; tool_tips[i].controlID != 0 && tool_tips[i].message != NULL; i++)
{
toolInfo.uId =(UINT_PTR)GetDlgItem(hMain,tool_tips[i].controlID);
toolInfo.lpszText = (LPSTR)tool_tips[i].message;
SendMessage(hTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
}
SendMessage(hTip, TTM_SETMAXTIPWIDTH, 0, max_tip_width);
return hTip;
} |
Partager