Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
Initializing TRect
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
IRC channel
Latest SVN
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Odd way of calculating th...
by
jamie
[
Today
at 01:40:34 am]
Getting basic state-depen...
by
jamie
[
Today
at 01:38:06 am]
DragDrop ghost image with...
by
jamie
[
Today
at 01:14:30 am]
Most primitive way for do...
by
Roland57
[April 20, 2021, 11:36:29 pm]
Find hex string in hex ed...
by
JCDes
[April 20, 2021, 11:30:06 pm]
Analogue of MessageDlg
by
jmpessoa
[April 20, 2021, 11:24:05 pm]
A poll about FPC +/ Lazar...
by
garlar27
[April 20, 2021, 10:50:44 pm]
Unfolding bug after searc...
by
Martin_fr
[April 20, 2021, 09:13:48 pm]
Compiling Linux project t...
by
pascal111
[April 20, 2021, 08:34:10 pm]
[fixed] problem with Char...
by
Muso
[April 20, 2021, 08:22:22 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Initializing TRect (Read 535 times)
del
Full Member
Posts: 197
Initializing TRect
«
on:
February 24, 2021, 03:06:35 pm »
According to:
https://www.freepascal.org/docs-html/current/rtl/objects/trect.copy.html
I can use
Code: Pascal
[Select]
[+]
[-]
m_mask
.
Assign
(
-
1
,
-
1
,
-
1
,
-
1
)
;
to initialize the TRect. But I get this error:
Quote
MyClasses.pas(438,9) Error: identifier idents no member "Assign"
However, when I use this form of initialization, everything is fine:
Code: Pascal
[Select]
[+]
[-]
m_mask
:
=
Rect
(
-
1
,
-
1
,
-
1
,
-
1
)
;
So obviously I found a solution. The variable m_mask is declared here:
Code: Pascal
[Select]
[+]
[-]
m_mask
:
TRect
;
FWIW.
«
Last Edit: February 24, 2021, 03:08:16 pm by del
»
Logged
howardpc
Hero Member
Posts: 3684
Re: Initializing TRect
«
Reply #1 on:
February 24, 2021, 04:10:37 pm »
To use TRect methods such as Assign you need the TRect declared in the Objects unit (as the documentation example shows).
«
Last Edit: February 24, 2021, 04:13:52 pm by howardpc
»
Logged
jcmontherock
Jr. Member
Posts: 63
Re: Initializing TRect
«
Reply #2 on:
February 24, 2021, 04:11:57 pm »
For that I am using: Rect := Bounds(Left, Top, Width, Height); and Rect.SetBounds(Left, Top, Width, Height);
Logged
GetMem
Hero Member
Posts: 4000
Re: Initializing TRect
«
Reply #3 on:
February 24, 2021, 05:35:40 pm »
@del
You can achieve the same result without the object unit, just use the cross platform CopyRect and EqualRect apis.
Code: Pascal
[Select]
[+]
[-]
uses
LCLIntf
;
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
var
R1
,
R2
,
R3
:
TRect
;
begin
R1
:
=
TRect
.
Create
(
10
,
100
,
50
,
200
)
;
R2
:
=
TRect
.
Create
(
10
,
100
,
50
,
200
)
;
R3
:
=
TRect
.
Create
(
-
1
,
-
1
,
-
1
,
-
1
)
;
CopyRect
(
R3
,
R2
)
;
if
EqualRect
(
R1
,
R3
)
then
ShowMessage
(
'Equal'
)
else
ShowMessage
(
'Not equal'
)
;
end
;
Logged
del
Full Member
Posts: 197
Re: Initializing TRect
«
Reply #4 on:
February 24, 2021, 09:31:53 pm »
Thanks everybody.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
Beginners
(Moderators:
FPK
,
Tomas Hajny
) »
Initializing TRect
TinyPortal
© 2005-2018