Andrew
Andrew

Reputation: 1618

SetWindowPos has not effect on tooltip

I am trying to give my ComboBox an in place tooltip for long strings. However when I call SetWindowPos on the tooltip, the position is never changed. Called when TTN_SHOW is received:

::SetWindowPos(textTooltip, NULL, TipRect.left, TipRect.top, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);

If I remove the SWP_NOSIZE flag and pop in some values into the width/height, then the combo box changes size to these values but the position remains the same. SetWindowPos always returns TRUE.

The tip is initialised like so:

        textTooltip = CreateWindowEx(WS_EX_TRANSPARENT, TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, this->GetSafeHwnd(), NULL, NULL, NULL);
        if(!textTooltip)
            return;

        ZeroMemory(&ToolInfo, sizeof(TOOLINFO));
        ToolInfo.cbSize = sizeof(TOOLINFO);
        ToolInfo.uFlags = TTF_TRANSPARENT | TTF_SUBCLASS; 
        ToolInfo.hwnd = this->GetSafeHwnd();
        ToolInfo.lpszText = "place holder"; //set in OnSelectChangeOk
        ToolInfo.uId = 0;   
        ToolInfo.rect = TipRect; //rect is re-set in OnSelectChangeOk

        ::SendMessage(textTooltip, TTM_ADDTOOL, 0, (LPARAM)&ToolInfo);

Am I missing something?

Upvotes: 1

Views: 1633

Answers (1)

humbagumba
humbagumba

Reputation: 2074

you gotta do ::SendMessage(hToolWnd, TTM_TRACKPOSITION, 0, MAKELPARAM(x, y)); and set the TTF_ABSOLUTE flag in the ToolInfo.uFlags member!

Fore more information, refer to: http://msdn.microsoft.com/en-us/library/bb760422(VS.85).aspx

Upvotes: 1

Related Questions