Wrong x, y ???

Started by
4 comments, last by Sixten 17 years, 10 months ago
Hiya all.. didnt really know what to put in the subject.. Well im developing a UI System that i will implement in my 3DEngine.. with buttons, textboxes and so on.. i got the rendering working smoothly and i got it working with transparent textures and so on.. But i got a problem with the Mouse handling.. The mouse X, Y from the MSGPROC dosent correspond with the X, Y on the screen.. If i have made a button and placed it at x:200, Y:200 and i move the mouse down to that X, Y pos.. the button is missplaced.. and the missplacement gets larger the bigger the x, y value is.. I have check that the X, Y pos is correct when the object is drawn.... What could cause this ?? I am drawing it at RHW (0.0f) and Z (0.0).. Its probobly something simple.. but i just cant find it ??.. And u one got any ideas..?? Thx for the help :D
Advertisement
I forget the exact details, but you might want to check the ScreenToClient() Win32 function. IIRC, the coordinates you're getting via Win32 aren't compensating for the border/title for your window, thus they appear incorrect...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by jollyjeffers
I forget the exact details, but you might want to check the ScreenToClient() Win32 function. IIRC, the coordinates you're getting via Win32 aren't compensating for the border/title for your window, thus they appear incorrect...

hth
Jack

I don't think this will solve the OP's problem as he says the misplacement gets larger if the x and y values of a control are greater.

@ OP: are your sure your viewport/projection matrix matches the client-rect of the window?

In screen coordinates, (0,0) is at the top left and X increases to the right and Y increases towards the bottom. In a normal 3D situation, (0,0) is in the center and X increases to the right and Y increases toward the top. Does this explain your behavior?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
I believe that I had this happen to me a while back...
Try and see if it still does it when your in fullscreen mode, (i'm assuming your windowed right now :)). If it does work correctly, then your problem is when windows creates a window to your specifications, it shrinks the client area to put in the outline, and the window title bar. So, what 20,20 to direct x, is not really 20,20 pixels from the corner of the winow.
~Mark Schadler
Well i have checked around alittle more.. and i noticed that the window created is only 791 wide and 564 high.. this is because of borders, and the top caption bar..

And i checked some sites and i found this function

AdjustWindowRect

All i had to do was to put my window size in a RECT and call this function like this and it resized the window :D

RECT rc;
SetRect( &rc, 0, 0, 800, 600 );
AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, false );

So now its pixel accurat :D

Thx anyways guys..

This topic is closed to new replies.

Advertisement