win32를 사용하여 함수 하나로 Tool Tip을 구현하는 방법
void CreateToolTipForRect(HWND hwndParent)
{
HINSTANCE hInst = (HINSTANCE) ::GetWindowLong(hwndParent,GWL_HINSTANCE);
INITCOMMONCONTROLSEX ic;
ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
ic.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&ic);
// Create a ToolTip.
HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
hwndParent, NULL, hInst,NULL);
SetWindowPos(hwndTT, HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
// Set up "tool" information.
// In this case, the "tool" is the entire parent window.
TOOLINFO ti = { 0 };
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hwndParent;
ti.hinst = hInst;
ti.lpszText = TEXT("This is your ToolTip string.");;
GetClientRect (hwndParent, &ti.rect);
// Associate the ToolTip with the "tool" window.
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
// SendMessage(hwndTT, TTM_ACTIVATE, true, NULL);
}
'프로그래밍 > TOOL & TIP' 카테고리의 다른 글
[MFC/VS2017] CSliderCtrl를 CDockablePane에 넣을 때 화면에 타나지 않은 문제 해결 (0) | 2019.04.20 |
---|