工具提示控件不会出现,但会被创建

时间:2016-07-01 06:36:03

标签: c winapi

我试图让工具提示出现在静态控件上。我几乎一字不差地跟着MSDN示例,但工具提示没有出现。也许我需要在创建工具提示之前初始化特定的公共控件?现在我初始化ICC_STANDARD_CLASSESICC_COOL_CLASSES

知道工具提示没有出现的原因吗?

case WM_CREATE:
{
    INITCOMMONCONTROLSEX iccx;
    iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    iccx.dwICC = ICC_STANDARD_CLASSES | ICC_COOL_CLASSES;
    InitCommonControlsEx(&iccx);

    HWND hwndTool = CreateWindowEx(0, _T("Static"), _T("Abc"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
        10, 10, 100, 100, hWnd, (HMENU)50001, hInst, NULL);

    HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
        WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
        CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT,
        hWnd, NULL,
        hInst, NULL);

    // Associate the tooltip with the tool.
    LPTSTR pszText = _T("Def");
    TOOLINFO toolInfo = { 0 };
    toolInfo.cbSize = sizeof(toolInfo);
    toolInfo.hwnd = hWnd;
    toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
    toolInfo.uId = (UINT_PTR)hwndTool;
    toolInfo.lpszText = pszText;

    output(_T("Is null: %d\n"), hwndTip == NULL); // output = Is null: 0
    output(_T("Send res: %d\n"), SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo)); // output = Send res: 0
}
break;

0 个答案:

没有答案