0

I use the dialog to confirm user actions:

TDialogService.MessageDialog('Question?', System.UITypes.TMsgDlgType.mtInformation,
[System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo],
System.UITypes.TMsgDlgBtn.mbNo, 0,

// Use an anonymous method to make sure the acknowledgment appears as expected.
procedure(const AResult: TModalResult)
begin
if Result = mrNo then
Exit
else begin
...
ProgressBar1.Visible := True;
ProgressBar1.Value := i;
Application.ProcessMessages;
...

But since MessageDialog is executed in a separate thread, nothing happens on the screen. How do I make the ProgressBar display and change its values?

I tried to turn on the timer before calling the dialog, changed the value of an external variable inside the dialog, and processed this value in the timer, but nothing happened

  • 1
    "*MessageDialog is executed in a separate thread*" - that is not true. It simply runs asynchronously instead. There is a difference. It still runs in the UI thread, it just doesnt block the caller. So you have to make sure that after `MessageDialog` returns to your code that you don't subsequently block the UI thread message loop so it can process the dialog and call your anonymous procedure when the dialog is closed. – Remy Lebeau Sep 01 '23 at 14:03

0 Answers0