Board index » delphi » Assigning Prect

Assigning Prect

hi,

I have a problem with assigning PRect.

Problem:

Following procedure causes access violation.

Procedure form1.area(sender:tobject);

var
  Tr:tRect;
  Pr:Prect;

begin
   Tr:=rect(0,0,400,400);  // compiled ok ran ok.
   Clipcursor(nil);              // compiled ok and ran ok.

  Pr^:=rect(0,0,400,400);  // Compiled ok but causes access violation.
                                         // without this line the program
runs ok and limits the
                                         // cursor to the top line of the
screen.

  Clipcursor(pr);

end;

Regards
Patrick

 

Re:Assigning Prect


patrick Clift <pcl...@dana.wanet.com.au> skrev i
diskussionsgruppsmeddelandet:380af0c...@news.highway1.com.au...

Quote
> hi,

> I have a problem with assigning PRect.

> Problem:

> Following procedure causes access violation.

> Procedure form1.area(sender:tobject);

> var
>   Tr:tRect;
>   Pr:Prect;

> begin
>    Tr:=rect(0,0,400,400);  // compiled ok ran ok.
>    Clipcursor(nil);              // compiled ok and ran ok.

>   Pr^:=rect(0,0,400,400);  // Compiled ok but causes access violation.
>                                          // without this line the program
> runs ok and limits the
>                                          // cursor to the top line of the
> screen.

>   Clipcursor(pr);

> end;

> Regards
> Patrick

Pr^:= Rect(0, 0, 400, 400);
This causes an access violation, because Pr isn't initialized yet. The
easiest way to achieve what you want is to use Tr instead of Pr -->
ClipCursor(@Tr);

Other Threads