bool CreateToolTip(int ID, HWND hwnd, const char *wtext) { if(!ID || !hwnd || !wtext) return false; HWND hwndTool = GetDlgItem(hwnd, ID); HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, NULL, ghInst, NULL); if(!hwndTool || !hwndTip) return false; TOOLINFO ti = {0}; ti.cbSize = sizeof(TOOLINFO); ti.hwnd = hwnd; ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.uId = (UINT_PTR)hwndTool; ti.lpszText = const_cast(wtext); SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti); SendMessage(hwndTip, TTM_SETMAXTIPWIDTH, 0, SHRT_MAX); // respect newline in tip text, this line is interesting, without it a "\n" within wtext will not be displayed as newline in the tooltip return true; };