MFC - Window Position
I need to know the position of the window my MFC app lies in screen coordinates. Unfortunately, functions such as GetWindowPos and GetWindowPlacement seem to only refer to client coordinates, and when I try and call them on the main window (rather than a dialog within that window or something), they return 0,0 for the upper left-hand position (which is incorrect). I've tried calling ClientToScreen on the resulting RECT, but that didn't really help either.
Is there another way to get the position of the main window of my MFC app?
Thanks!
Hi CyberSlag5k,
Have you tried GetWindowInfo? It takes a WINDOWINFO, which has both screen and client coordinates. And it looks like its a MFC has the same function under CWnd, so I would give that a try.
-brad
Have you tried GetWindowInfo? It takes a WINDOWINFO, which has both screen and client coordinates. And it looks like its a MFC has the same function under CWnd, so I would give that a try.
-brad
Thanks for the suggestions, guys.
Both WINDOWINFO and GetWindowInfo come up as undeclared identifiers. Perhaps it's just my version of MFC (though I believe it is the latest, and it does show up under intellisense).
Also, GetWindowRect doesn't seem to take 2 parameters, though I thought there was a similar function that did, but I looked and didn't find it.
I did like both suggestions, though, so if there's something I can tweak to get either working, I'm game.
Thanks again!
Both WINDOWINFO and GetWindowInfo come up as undeclared identifiers. Perhaps it's just my version of MFC (though I believe it is the latest, and it does show up under intellisense).
Also, GetWindowRect doesn't seem to take 2 parameters, though I thought there was a similar function that did, but I looked and didn't find it.
I did like both suggestions, though, so if there's something I can tweak to get either working, I'm game.
Thanks again!
hmmm odd,
RECT rect;
::GetWindowRect(GetSafeHwnd(), &rect);
or
RECT rect;
GetWindowRect(&rect);
should work for MFC.
RECT rect;
::GetWindowRect(GetSafeHwnd(), &rect);
or
RECT rect;
GetWindowRect(&rect);
should work for MFC.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement