Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#1

Show thread progress in modal window

  Alt 21. Jan 2013, 11:58
Delphi-Version: 5
Delphi-Quellcode:
type
  TCheckThread = class(TThread)
  private
    FDialog: TProcessingDialog;
    procedure DoCheck;
  protected
    procedure Execute; override;
  public
    constructor Create(CreateSuspended: Boolean);
    destructor Destroy; override;
  end;

constructor TCheckThread.Create(CreateSuspended: Boolean);
begin
  inherited Create(CreateSuspended);

  FDialog := TProcessingDialog.Create(Application);
  FDialog.ShowModal;
end;

destructor TCheckThread.Destroy;
begin
  FDialog.Free;

  inherited Destroy;
end;

procedure TCheckThread.DoCheck;
var
  //...
begin
  MainForm.lblHint.Visible := False;

  FDialog.tbProgress.Max := MainForm.CheckedCount;

  for I := 0 to MainForm.lvList.Items.Count - 1 do
  begin
    if Terminated then Exit;

     //...
  end;

  FDialog.Close;
end;

procedure TCheckThread.Execute;
begin
  Synchronize(DoCheck);
end;
But after ShowModal it waiting for ModalResult. How I can use modal window inside thread?
  Mit Zitat antworten Zitat