Hey guys,
I have a weird problem I can't figure out:
This code is meant to calculate a position of a window and put it there. And it pretty much works just fine, the window appears where it is supposed to be. The only issue with it is I really need the final line to make it a topmost window.
case WM_NOTIFY:
{
if (wParam == MEW_TOOLTIPWINDOW || wParam == EW_TOOLTIPWINDOW)
{
if (((NMHDR*)lParam)->code == EN_REQUESTRESIZE)
{
ReqResize = (REQRESIZE*)lParam;
GetWindowRect(EnhancementWindowHandle, &WindowRect);
GetCursorPos(&CursorPoint);
X = CursorPoint.x - WindowRect.left+10;
Y = CursorPoint.y - WindowRect.top+10;
//don't fall off the bottom of the main window
if (Y + (ReqResize->rc.bottom - ReqResize->rc.top) > (WindowRect.bottom - WindowRect.top))
Y = (WindowRect.bottom - WindowRect.top) - (ReqResize->rc.bottom - ReqResize->rc.top);
//also, don't go past the right side of the main window
if (X + (ReqResize->rc.right - ReqResize->rc.left) > (WindowRect.right - WindowRect.left))
X = (CursorPoint.x - WindowRect.left) - (ReqResize->rc.right - ReqResize->rc.left) - 10;
//at this point we should be entirely inside the window, unless the text is so large the tooltip is higher than the entire window itself.
// TODO: Handle fringe case of too tall a tooltip window...
SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOP, X, Y, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_SHOWWINDOW);
}
}
return 0;
}
so I changed the final line to such:
SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOPMOST, X, Y, ReqResize->rc.right - ReqResize->rc.left, ReqResize->rc.bottom - ReqResize->rc.top, SWP_SHOWWINDOW);
That's the only change I made, just changed HWND_TOP to HWND_TOPMOST. And the result is the window no longer resizes or moves. It is in it's default size at parent window 0,0. The return value of the function does not indicate a failure (return is non-zero), it just doesn't do what I expect it to do.
I even tried forcing it to move:
SetWindowPos(ReqResize->nmhdr.hwndFrom, HWND_TOPMOST, 100, 100, 500, 500, SWP_SHOWWINDOW);
Same thing, it is ignoring the x, y, sizex, and sizey parameters when using HWND_TOPMOST
Any ideas why? What am I doing wrong?