Jump to content

  • Log In with Google      Sign In   
  • Create Account


RECT not working properly


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 20 October 2012 - 04:06 AM

I'm trying to use the following:

a rect structure: Click to acces page
and the function for a rect structure called PtInRect: Click to acces page

So I have the following code:

[source lang="cpp"]RECT testtest.bottom = 0; test.top = height_of_window; test.right = width_of_window / 2; test.left = -width_of_window / 2;void OnMouseDown(WPARAM btnState, int x, int y){ mLastMousePos.x = x; mLastMousePos.y = y; SetCapture(mhMainWnd); POINT xa; xa.x = mLastMousePos.x; xa.y = mLastMousePos.y; if(PtInRect(&test,xa)) MessageBox(NULL,L"FOUND",L"FOUND",NULL);}[/source]

First: I tested the mousedown function,when a button just clicks,it works properly!

As you can see I created a rectangle half of the height of the screen,and full width of the screen.The above code should make any click in the upper part of the screen show a messagebox,however,this doesn't happent!

What am I doing wrong?

Edited by noatom, 20 October 2012 - 04:09 AM.


Sponsor:

#2 Aardvajk   Crossbones+   -  Reputation: 5957

Like
2Likes
Like

Posted 20 October 2012 - 04:34 AM

You've got your rect coords wrong. Screen coords run from 0 to height down the screen and 0 to width across.

Top half of screen rect would be:

top = 0
left = 0
right = width
bottom = height / 2

HTH

#3 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 20 October 2012 - 05:47 AM

thanks,it worked




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS