Recent

Author Topic: TMemo Not Responding After Button Click  (Read 2128 times)

Dytlyf

  • New member
  • *
  • Posts: 6
TMemo Not Responding After Button Click
« on: May 21, 2013, 10:52:31 am »
Hi all,

I have a puzzling little problem. Unfortunately my code is bulky, so I'll briefly explain what happens instead of copying code.

I have a Memo component for displaying messages, two Buttons and a ComboBox. When I click on Button1, event handling Procedure1 is called. In this procedure I use Synaser to connect to a modem. Various AT commands are sent, and the replies are displayed in Memo. At the end of Procedure1, a prompt is displayed to inform the user to select and item from ComboBox and click Button2. Up to this point everything works very nicely and all the messages are displayed one line at a time with

Code: [Select]
Memo.Lines.Add('some text')
Now I scroll to a line in ComboBox and click on Button2, which calls event handler Procedure2. At the very start of Procedure2 I have the statement,

Code: [Select]
Memo.Lines.Text := 'Please wait...';
The idea is to warn the user that the next process will take some time, which it does, because again I send AT commands to the modem, some of which take seconds to respond. As in Procedure1, the replies are written to Memo.

However, this is the problem: everything works OK in Procedure2, except that the messages only appear when Procedure 2 ends, and not during its execution, as is the case with Procedure1. So, what is different that makes the text appear in Memo during execution of Procedure1, but not during execution of Procedure? Everything else works without problems.

Any ideas, anyone?

Thanks.

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: TMemo Not Responding After Button Click
« Reply #1 on: May 21, 2013, 11:41:13 am »
Window events are normally done after your procedure ends, so paint events for memo will only update then. You can do that manually like:
Code: [Select]
Memo.Lines.Text := 'Please wait...';
Application.ProcessMessages;

Dytlyf

  • New member
  • *
  • Posts: 6
Re: TMemo Not Responding After Button Click
« Reply #2 on: May 21, 2013, 04:19:32 pm »
Thanks, User137. That solved the problem.