this code works fine:
procedure TForm2.Timer1Timer(Sender: TObject);
var
Text: string;
begin SetLength (Text,555);
GetWindowText (getforegroundwindow, PChar (Text),555);
Form2.gtListBox1.Items.Add (
IntToStr (getforegroundwindow) + ': ' + Text);
end;
but when I put
var
Text: string;
from the Timer1Timer event handler to the block implementation section or `` text: string '' in units of var section I get error: E2197 A constant object cannot be passed as a var parameter
according to the documentation:
This error message appears when you try to send a constant as a var or out parameter to a function or procedure.
but I did not declare the text as permanent, why am I getting this error?
Edit: @mason wheeler: I don't understand why this works:
implementation
{$R *.dfm}
var
char :integer;
procedure TForm2.Button1Click(Sender: TObject);
begin
char:=11;
showmessage(IntToStr(char));
end;
, , : '' , '', ?
Edit2: , , . , delphi , :
with
form1 do
text := 'blahblahblah';
delphi, , delphi text := 'blah', form1.text := blah; with form1 do text := 'blah'; / , delphi 2010 -