PtInRect

Started by ajige, February 10, 2009, 09:37:19 PM

Previous topic - Next topic

ajige

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:

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
if(PtInRect(&rectBoard,*((LPPOINT)&pt)))
Compiles fine, but same result, always false
   
My work-around code is:
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

Have you tried having the right values so that the POINT is within the RECT?


RECT rectBoard = {0,0,10,10}; 
POINT pt = {2,2};
if(PtInRect(&rectBoard, pt)){


John

ajige

Sorry, I forgot to include the code for where the points come frem. Here is a more complete copy of the code:

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 :
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

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