函数逻辑简单,直接贴出函数代码: HWND WINAPI CreateToolTip(HWND hwndOwner, LPCTSTR szTip) { INITCOMMONCONTROLSEX iccex; HWND hwndTT; // handle to the ToolTip control TOOLINFO ti; unsigned int uid = 0; // for ti initialization RECT rect; // for client area coordinates /* INITIALIZE COMMON CONTROLS */ iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); /* CREATE A TOOLTIP WINDOW */ hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, gAppInstance, NULL ); SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); /* GET COORDINATES OF THE MAIN CLIENT AREA */ GetClientRect (hwndOwner, &rect); /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */ ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndOwner; ti.hinst = gAppInstance; ti.uId = uid; ti.lpszText = (LPTSTR)szTip; // ToolTip control will cover the whole window ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; ti.rect.bottom = rect.bottom; /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */ SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); return hwndTT; } 调用举例: CreateToolTip(GetDlgItem(hDlg, IDC_STATIC_SERVER_STAT), FileNameStr); 注意两点:1、STATIC控件ID不能是默认的ID(IDC_STATIC) 2、在设计器中将STATIC Notify通知消息设置为TRUE