1. Computing
Glossary|Tips/Tricks|FREE App/VCL|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit

PtInRect

unit
Types
category
Geometric routines
declaration

function PtInRect(const ARect: TRect; const APoint: TPoint): Boolean;

description
Returns true if a specified point lies inside a specified rectangle.

APoint IS inside a rectangle if it lies on the left or top edge, but NOT if it lies on the right or bottom edge of ARect. If ARect has negative width or height the function returns False.

example
var CurPos: TPoint;
    ARect :TRect;
    
GetCursorPos(CurPos);
ARect := Rect(Screen.DesktopLeft, 
              Screen.DesktopRight, 
              Screen.DesktopWidth div 2, 
              Screen.DesktopHeight div 2)
              
// find if the sursor is 
//below the center of the screen desktop area

if PtInRect(ARect, CurPos) then 
  ShowMessage('Move up your cursor ;)');
in real code
Zoom
How to write a Delphi application that is able to zoom in portion of your desktop screen.
TScreen demystified
Coding the TScreen object, obtainer of all information about the current state of the screen in a Delphi application.
see also
Rect


Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

Got some code to share? Got a question? Need some help?
See More About

©2013 About.com. All rights reserved.