Forum > Beginners

[Solved] PtInRect

(1/2) > >>

Bram_Steijn:
Hello,

First off, I am afraid that even "a beginner" is not an accurate enough description for me(!), so my question is undoubtedly going to be rather silly.

I am trying to implement a piece of code into the MouseMove Procedure for my Form1. I have scoured Google and found various potential solution to my problem. Most of these solutions involve using PtInRect to check if the mouse is hovering over a, say, button. However, whenever I try and use PtInRect, Lazarus tells me it is not a valid identifier. Am I missing something or is PtInRect simply not a valid command?

Many thanks,
Bram

wp:
Do you have "Types" in the "uses" clause? If this does not solve the issue then you should post the code in which you call "PtInRect"

Bram_Steijn:
Nope, I did not! I thought that I was missing something in the uses section, but couldn't find anywhere what it might be.

Thanks a lot!

wp:
"Types", "LCLIntf","LCLType" and "LCLProc" are always good candidates when searching for missing units.

goomoo:

function PtInRect(ARect:TRect;APoint:TPoint):Boolean;
Begin
  if (APoint.X>ARect.Left) and (APoint.Y>ARect.Top)
    and (APoint.X<ARect.Right) and (APoint.Y < ARect.Bottom) then
  Begin
    PtInRect:=True;
    Exit;
  end;

  PtInRect:=False;
end;

Navigation

[0] Message Index

[#] Next page

Go to full version