Hi,
I try to update a component text property periodically ...
example:
put a TBbutton on a form,
add the following code to the OnClick event:
{code}
procedure TForm1.Button1Click(Sender: TObject);
var i : integer;
begin
for i := 1 to 1000000 do begin
if i mod 1000 = 0 then begin
button1.Text := inttostr(i);
button1.Repaint;
// have tried "Realign" too...
end;
end;
end;
{code}
From my point of view, this routine should update the component
every thousand steps... I have tried .realign too... without success...
Any idea how to refresh a firemonkey component or the whole form/scene?
Tia,
Peter
Edited by: Peter Wichenthaler-Sternbach on Nov 7, 2011 2:40 AM
Vote for best question.
Score: 0
# Vote: 0
Date Posted: 7-Nov-2011, at 6:41 AM EST
From: Peter Wichenthaler-Sternbach
Re: how to refresh/repaint/invalidate a component in firemon
> {quote:title=Peter Wichenthaler-Sternbach wrote:}{quote}
> Hi,
>
> I try to update a component text property periodically ...
>
> example:
>
> put a TBbutton on a form,
>
> add the following code to the OnClick event:
>
> {code}
> procedure TForm1.Button1Click(Sender: TObject);
>
> var i : integer;
>
> begin
The form will repaint if you use TForm1.Invalidate. Try that.
Scott
> for i := 1 to 1000000 do begin
> if i mod 1000 = 0 then begin
> button1.Text := inttostr(i);
> button1.Repaint;
> // have tried "Realign" too...
> end;
> end;
> end;
> {code}
>
> From my point of view, this routine should update the component
> every thousand steps... I have tried .realign too... without success...
>
> Any idea how to refresh a firemonkey component or the whole form/scene?
>
> Tia,
>
> Peter
>
> Edited by: Peter Wichenthaler-Sternbach on Nov 7, 2011 2:40 AM
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 7-Nov-2011, at 11:30 AM EST
From: Scott Hochberg
Re: how to refresh/repaint/invalidate a component in firemon
> {quote:title=Scott Hochberg wrote:}{quote}
> > {quote:title=Peter Wichenthaler-Sternbach wrote:}{quote}
> > Hi,
> >
> > I try to update a component text property periodically ...
> >
> > example:
> >
> > put a TBbutton on a form,
> >
> > add the following code to the OnClick event:
> >
> > {code}
> > procedure TForm1.Button1Click(Sender: TObject);
> >
> > var i : integer;
> >
> > begin
>
> > for i := 1 to 1000000 do begin
> > if i mod 1000 = 0 then begin
> > button1.Text := inttostr(i);
> > button1.Repaint;
> > // have tried "Realign" too...
> > end;
> > end;
> > end;
> > {code}
> >
> > From my point of view, this routine should update the component
> > every thousand steps... I have tried .realign too... without success...
> >
> > Any idea how to refresh a firemonkey component or the whole form/scene?
> >
> > Tia,
> >
> > Peter
> >
> > Edited by: Peter Wichenthaler-Sternbach on Nov 7, 2011 2:40 AM
Sorry, let me try this again - my reply got stuck in the middle of your question --
The form will repaint if you use TForm1.Invalidate. Try that.
Scott
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 7-Nov-2011, at 11:32 AM EST
From: Scott Hochberg
Re: how to refresh/repaint/invalidate a component in firemon
> {quote:title=Scott Hochberg wrote:}{quote}
> > {quote:title=Scott Hochberg wrote:}{quote}
> > > {quote:title=Peter Wichenthaler-Sternbach wrote:}{quote}
> > > Hi,
> > >
> > > I try to update a component text property periodically ...
> > >
> > > example:
> > >
> > > put a TBbutton on a form,
> > >
> > > add the following code to the OnClick event:
> > >
> > > {code}
> > > procedure TForm1.Button1Click(Sender: TObject);
> > >
> > > var i : integer;
> > >
> > > begin
> >
> > > for i := 1 to 1000000 do begin
> > > if i mod 1000 = 0 then begin
> > > button1.Text := inttostr(i);
> > > button1.Repaint;
> > > // have tried "Realign" too...
> > > end;
> > > end;
> > > end;
> > > {code}
> > >
> > > From my point of view, this routine should update the component
> > > every thousand steps... I have tried .realign too... without success...
> > >
> > > Any idea how to refresh a firemonkey component or the whole form/scene?
> > >
> > > Tia,
> > >
> > > Peter
> > >
> > > Edited by: Peter Wichenthaler-Sternbach on Nov 7, 2011 2:40 AM
>
> Sorry, let me try this again - my reply got stuck in the middle of your question --
>
> The form will repaint if you use TForm1.Invalidate. Try that.
>
> Scott
Hello Scott,
I've tried Form1.Invalidate too, still no effect here. Btw, I'm using update 2, it did not work under update 1 either...
Regards,
Peter
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 7-Nov-2011, at 11:50 AM EST
From: Peter Wichenthaler-Sternbach
Re: how to refresh/repaint/invalidate a component in firemon
Peter Wichenthaler-Sternbach wrote:
> Any idea how to refresh a firemonkey component or the whole
> form/scene?
Weird. This should work. But it does not, indeed. It does work when you
use an Application.ProcessMessages, but that slows stuff down too much.
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 7-Nov-2011, at 12:33 PM EST
From: Dominique Willems
Re: how to refresh/repaint/invalidate a component in firemon
Peter Wichenthaler-Sternbach wrote:
> button1.Text := inttostr(i);
Compromise, but fast, is to use
button1.Text := inttostr(i);
Application.HandleMessage
No Repaint necessary.
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 7-Nov-2011, at 12:55 PM EST
From: Dominique Willems
Re: how to refresh/repaint/invalidate a component in firemon
> {quote:title=Dominique Willems wrote:}{quote}
> Peter Wichenthaler-Sternbach wrote:
> > button1.Text := inttostr(i);
>
> Compromise, but fast, is to use
>
> button1.Text := inttostr(i);
> Application.HandleMessage
>
> No Repaint necessary.
Super - many thanks - this is really working. I haven't noticed that Application.ProcessMessages
& co is aboard in Firemonkey now...
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 8-Nov-2011, at 1:17 AM EST
From: Peter Wichenthaler-Sternbach
Re: how to refresh/repaint/invalidate a component in firemon
I've tried to apply the suggestions in this thread to my solve my problem, but it's not working. I have a FireMonkey TListBox that won't repaint. I've tried:
ListBox1.InvalidateRect(RectF(0,0,width,height));
ListBox1.Realign;
Application.ProcessMessages;
Application.HandleMessage;
None of the above work. Any thoughts?
> {quote:title=Peter Wichenthaler-Sternbach wrote:}{quote}
> > {quote:title=Dominique Willems wrote:}{quote}
> > Peter Wichenthaler-Sternbach wrote:
> > > button1.Text := inttostr(i);
> >
> > Compromise, but fast, is to use
> >
> > button1.Text := inttostr(i);
> > Application.HandleMessage
> >
> > No Repaint necessary.
>
> Super - many thanks - this is really working. I haven't noticed that Application.ProcessMessages
> & co is aboard in Firemonkey now...
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 17-Jan-2012, at 2:03 PM EST
From: Daryl Erwin
Re: how to refresh/repaint/invalidate a component in firemon
> {quote:title=Daryl Erwin wrote:}{quote}
> I've tried to apply the suggestions in this thread to my solve my problem, but it's not working. I have a FireMonkey TListBox that won't repaint. I've tried:
> ListBox1.InvalidateRect(RectF(0,0,width,height));
> ListBox1.Realign;
> Application.ProcessMessages;
> Application.HandleMessage;
> None of the above work. Any thoughts?
>
>
> > {quote:title=Peter Wichenthaler-Sternbach wrote:}{quote}
> > > {quote:title=Dominique Willems wrote:}{quote}
> > > Peter Wichenthaler-Sternbach wrote:
> > > > button1.Text := inttostr(i);
> > >
> > > Compromise, but fast, is to use
> > >
> > > button1.Text := inttostr(i);
> > > Application.HandleMessage
> > >
> > > No Repaint necessary.
> >
> > Super - many thanks - this is really working. I haven't noticed that Application.ProcessMessages
> > & co is aboard in Firemonkey now...
Hello,
Well if you want to repaint the form while still in executing the callback of a button, you shall start a new Thread, because the callback actualy blocks your interface.
Stefan
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 18-Jan-2012, at 7:56 AM EST
From: Stefan Baciu
Re: how to refresh/repaint/invalidate a component in firemon
> {quote:title=Stefan Baciu wrote:}{quote}
> > {quote:title=Daryl Erwin wrote:}{quote}
> > I've tried to apply the suggestions in this thread to my solve my problem, but it's not working. I have a FireMonkey TListBox that won't repaint. I've tried:
> > ListBox1.InvalidateRect(RectF(0,0,width,height));
> > ListBox1.Realign;
> > Application.ProcessMessages;
> > Application.HandleMessage;
> > None of the above work. Any thoughts?
> >
> >
> > > {quote:title=Peter Wichenthaler-Sternbach wrote:}{quote}
> > > > {quote:title=Dominique Willems wrote:}{quote}
> > > > Peter Wichenthaler-Sternbach wrote:
> > > > > button1.Text := inttostr(i);
> > > >
> > > > Compromise, but fast, is to use
> > > >
> > > > button1.Text := inttostr(i);
> > > > Application.HandleMessage
> > > >
> > > > No Repaint necessary.
> > >
> > > Super - many thanks - this is really working. I haven't noticed that Application.ProcessMessages
> > > & co is aboard in Firemonkey now...
>
> Hello,
>
> Well if you want to repaint the form while still in executing the callback of a button, you shall start a new Thread, because the callback actualy blocks your interface.
>
> Stefan
I'm not sure I follow what you mean. I'll give a little more detail. I've built a simple client/server chat program. A message comes in from the client, which is displayed in TListBox. Then the server app waits until a TCheckBox is checked, then sends a response back to the client, and displays it response in its TListBox. Here's my procedure:
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var str: string;
begin
str:= AContext.Connection.IOHandler.ReadLn();
ListBox1.Items.Add(AContext.Connection.Socket.Binding.PeerIP + ':' + IntToStr(AContext.Connection.Socket.Binding.PeerPort) + ': ' + str);
ListBox1.ItemIndex:= ListBox1.Items.Count -1;
while not DoneCheck.IsChecked do
Delay(500);
AContext.Connection.IOHandler.WriteLn(ReplyEdit.Text);
ListBox1.Items.Add('Me: ' + ReplyEdit.Text);
ListBox1.ItemIndex:= ListBox1.Items.Count -1;
DoneCheck.IsChecked:= False;
end;