NO

Author Topic: PtInRect  (Read 2537 times)

ajige

  • Guest
PtInRect
« on: February 10, 2009, 09:37:19 pm »
I have programmed for my Pocket PC earlier in C# and Pascal, but have decided to try straight c with PellesC.

I going through the book "Programming for WindowsCE" in order to learn Windows programming in c.
I have the following problem with the PtInRect function:
Code: [Select]
The original code from the book:
RECT rectBoard = {0,0,0,0}; 
POINT pt;
if(PtInRect(&rectBoard, pt))
compiles fine, but always returns false

I've also tried
Code: [Select]
if(PtInRect(&rectBoard,*((LPPOINT)&pt)))Compiles fine, but same result, always false
   
My work-around code is:
Code: [Select]
if (pt.x<rectBoard.right &&pt.x>rectBoard.left &&pt.y>rectBoard.top && pt.y <rectBoard.bottom)This compiles fine, and returns true, when within the rectBoard border.

Any ideas why PtInRect doesn't work?


JohnF

  • Guest
Re: PtInRect
« Reply #1 on: February 10, 2009, 09:48:36 pm »
Have you tried having the right values so that the POINT is within the RECT?

Code: [Select]
RECT rectBoard = {0,0,10,10}; 
POINT pt = {2,2};
if(PtInRect(&rectBoard, pt)){

John

ajige

  • Guest
Re: PtInRect
« Reply #2 on: February 10, 2009, 10:53:43 pm »
Sorry, I forgot to include the code for where the points come frem. Here is a more complete copy of the code:
Code: [Select]
LRESULT DoLButtonUpMain (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
POINT pt;
INT cx,cy,nCell=0;
pt.x=LOWORD (lParam);
pt.y = HIWORD (lParam);
if (PtInRect (&rectBoard, pt))

I also tried :
Code: [Select]
RECT rectBoard = {0,0,10,10}; 
POINT pt = {2,2};
if(PtInRect(&rectBoard, pt)){
MessageBox (hWnd, TEXT("Up"), szAppName, MB_OK);
}
Still no results.


Thanks for trying!

JohnF

  • Guest
Re: PtInRect
« Reply #3 on: February 11, 2009, 10:51:08 am »
Well I'm surprised, it works here on a normal PC, (I don't have a pocket PC) but would expect PtInRect() to behave the same.

John