There are several possible solutions.
program Test;
uses Objects, Views, Dialogs, App, Crt;
type
PMyDialog = ^TMyDialog;
TMyDialog = object(TDialog)
constructor Init;
end;
var
MyText : PStaticText;
constructor TMyDialog.Init;
var
R : TRect;
begin
R.Assign(0,0, 20,10);
inherited Init(R, 'Demo');
Options := Options or ofCentered;
R.Assign(0,0,5,1);
MyText := New(PStaticText, Init(R, '0'));
MyText^.Options := MyText^.Options or ofCentered;
Insert(MyText);
R.Assign(4,7, 14,9);
Insert(New(PButton, Init(R, 'O~K~', cmOK, bfDefault)));
end;
var
MyApp : TApplication;
s : string;
i : word;
begin
MyApp.Init;
DeskTop^.Insert(New(PMyDialog, Init));
for i := 1 to 100 do begin
DisposeStr(MyText^.Text);
Str(i:3, s);
MyText^.Text := NewStr(s);
MyText^.DrawView;
Delay(100);
end;
MyApp.Done;
end.
This solution relies on having a pointer to a static text. The text of this static text is changed and the
now dynamic text is redrawn with a call to its DrawView method. There are other solutions, see
A2 and A3.
for i := 1 to 100 do begin
Str(i:3, s);
MyInputLine^.SetData(s);
Delay(100);
end;
A call to DrawView is not necessary anymore as SetData should redraw itself.
for i := 1 to 100 do begin
Str(i:3, s);
Message(DeskTop, evBroadCast, cmChangeDynamicText, @s);
Delay(100);
end;