Sign in to follow this  
Reegan

GetWindowInfo(...) has gone up insane!

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
@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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
Quote:
Original post by Reegan
rcClient.left is always 0 same goes for rcClient.top (or rather, it should always be 0)
Why? It doesn't say that anywhere in the documentation that I'm aware of. It's that reason that I always get the client area size by subtracting the left and top sides of the client area.

Just because GetClientRect() returns coordinates based at (0, 0) doesn't mean that all Win32 functions should.

Share this post


Link to post
Share on other sites
hmmmm, you are right, to me that is really weird coming from using the GetClientRect() function.

and it doesnt say anywhere in the documentation (that i can see) that the rcClient.left / rcClient.top is measured from the edge of the screen coordinates up to the edges of the client area.

hmmm this is going to make for some pretty 'hefty' code lines >.<
sometimes i hate OOP..

Thanks, for the lesson on WINDOWINFO's rcClient

~Reegan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this