GetWindowInfo(...) has gone up insane!

Started by
10 comments, last by Reegan 15 years, 5 months ago
Well heres the thing im using the WINDOWINFO structure for the same reason it exists.. but theres a problem with mine, and i cant figure it out, ive done what the documentation has said. and heres a screen shot of the values at runtime: http://img150.imageshack.us/my.php?image=failfb4.png As you can see, the values are completely out of whack for the window. any help? In particular, notice the values for rcClient struct. the size of my window is 800x600
Advertisement
Is m_hWnd definitely valid and referring to the window you think it is? And what does GetWindowInfo return? If it's zero, then the WINDOWINFO struct won't be filled in (Which is what it looks like is happening).
To answer your questions:

1) yes the m_hWnd is valid as it is passed to other functions that depend on it, and work without a problem.

2) I havent checked the return value, but i did use the function RtlZeroMemory() (further above in that code you can see, although you may not be able to see the actual line from that screen shot. so shouldnt the values all be NULL if the function failed?
Quote:Original post by Reegan
To answer your questions:

1) yes the m_hWnd is valid as it is passed to other functions that depend on it, and work without a problem.

2) I havent checked the return value, but i did use the function RtlZeroMemory() (further above in that code you can see, although you may not be able to see the actual line from that screen shot. so shouldnt the values all be NULL if the function failed?
Ah, I see. Yes, the function will just not touch the values rather than fill them with gibberish.
Are you sure the HWND is for the window you think it is (I.e. try using SetWindowText to set the caption)? That's just about the only thing I can think of. Failing that, try doing a clean build and see if the problem is still there.
Yes the lpWnd->m_hWnd is working fine, i tested it with setting the window caption like you had asked. Also done a clean and rebuild but no changes
I can't see the window on your task bar - are you sure it's being created properly? Also, you could try calling ShowWindow() & UpdateWindow() before getting the window info.

Otherwise, check the return value and call GetLastError() if necessary.
The values look ok to me. It's just weird that the client coordinates seem to be passed as screen coordinates as well.

Can be useful though.

Why not use GetWindowPlacement?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

@Beeps: yes the window is being created properly if something else was wrong i would be asking questions about that or trying t fix it on my own, but no, everything is fine except the WINDOWINFO struct.

@Endurion: Ok then, so im using the WINDOWINFO struct wrong, or microsoft have made a mistake?


Thanks for your time
~Reegan
Quote:Original post by Reegan
@Endurion: Ok then, so im using the WINDOWINFO struct wrong, or microsoft have made a mistake?
You're using it wrong - the rcClient is the rectangle for the client area, not just it's size. So the client area size is (rcClient.right - rcClient.left, rcClient.bottom - rcClient.top). And you can see that rcClient.right-rcClient.left + cxWindowBorders*2 == 800.
Im afraid to tell you, that im not using it wrong, before i used WindowGetInfo(...) i used to use GetClientRect(...) which works just fine for the client rect.

There is something wrong with WindowGetInfo(...)

sorry that you guys couldnt figure it out =/

EDIT:
Quote:rcClient.right-rcClient.left + cxWindowBorders*2 == 800.

rcClient.left is always 0 same goes for rcClient.top (or rather, it should always be 0)

This topic is closed to new replies.

Advertisement