Recent

Author Topic: how can i send parent to procedure ?  (Read 666 times)

majid.ebru

  • Hero Member
  • *****
  • Posts: 502
how can i send parent to procedure ?
« on: May 25, 2023, 06:45:32 am »
Hi

can sombody help or gide me ?

in this code :

Code: Pascal  [Select][+][-]
  1.   with(mainForm.FindComponent(strSTG)as TStringGrid)do begin
  2.  
  3.         movRow(Row,Row + 1,  ? );
  4.        //  => What command should I write instead of the question mark?
  5.       //   Self  or This or ....?
  6.   end;  

how can i send parent to procedure?

thank you
« Last Edit: May 25, 2023, 07:09:14 am by majid.ebru »

TRon

  • Hero Member
  • *****
  • Posts: 2518
Re: how cn i send parent to procedure ?
« Reply #1 on: May 25, 2023, 06:55:37 am »
Perhaps ?

Code: Pascal  [Select][+][-]
  1. var
  2.   SomeGrid : TStringGrid
  3. ...
  4. begin
  5. ..
  6.   SomeGrid:= MainForm.FindComponent(strSTG) as TStringGrid
  7.   with SomeGrid do
  8.   begin
  9.     movRow(Row, Row + 1, SomeGrid)
  10.     ..
  11.   end
  12. ...
  13. end
  14.  

majid.ebru

  • Hero Member
  • *****
  • Posts: 502
Re: how cn i send parent to procedure ?
« Reply #2 on: May 25, 2023, 07:01:14 am »
Is it possible to do that without defining a new TStringgrid ?

TRon

  • Hero Member
  • *****
  • Posts: 2518
Re: how cn i send parent to procedure ?
« Reply #3 on: May 25, 2023, 07:07:48 am »
To make clear: You do not define a new stringgrid only a reference to it.

And I have no idea if you could do without as the snippet you posted is too small to be able to provide an (accurate) answer. There is absolutely no context atm.

When using the with statement it is not possible to reference the (in this case) object other then the example I provided (unless there is additional context that might be able to help you out there)
« Last Edit: May 25, 2023, 07:11:37 am by TRon »

majid.ebru

  • Hero Member
  • *****
  • Posts: 502
Re: how can i send parent to procedure ?
« Reply #4 on: May 25, 2023, 07:13:03 am »
Thank you :)

cdbc

  • Hero Member
  • *****
  • Posts: 1083
    • http://www.cdbc.dk
Re: how can i send parent to procedure ?
« Reply #5 on: May 25, 2023, 12:04:53 pm »
Hi
Ok, here comes nasty!
If you beforehand, store a reference to the stringgrid in its own "Tag" property:
Code: Pascal  [Select][+][-]
  1. procedure TmainForm.FormCreate(Sender: TObject);
  2. begin
  3.   StringGrid1.Tag:= ptrint(StringGrid1); // <- nasty business!
  4. end;
  5.  

then you would be able to do something like this:
Code: Pascal  [Select][+][-]
  1.   with(mainForm.FindComponent(strSTG)as TStringGrid)do begin
  2.     movRow(Row,Row + 1, TStringGrid(Tag)); // <- nasty business!
  3.   end;
  4.  
%) It was the voices, they told me to do so....  O:-)
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018