AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Show dialog when processing data

Ein Thema von WojTec · begonnen am 30. Jun 2011 · letzter Beitrag vom 30. Jun 2011
Antwort Antwort
WojTec

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

Show dialog when processing data

  Alt 30. Jun 2011, 08:35
Delphi-Version: 2010
Here is pseudocode which demonstrate what I want to tell:

Delphi-Quellcode:
CreateAndShowDialog();

MakeSomeTaskWhichNeedManyCPUTime()

DestroyDialog();
Dialog contain animated marquee. Normally I'm, creating it, showing in modal mode and then call Invalidate(), but then Windows don't refresh animation. How to show this dialog during data processing and do not lock it update?
  Mit Zitat antworten Zitat
Benutzerbild von Memnarch
Memnarch

Registriert seit: 24. Sep 2010
737 Beiträge
 
#2

AW: Show dialog when processing data

  Alt 30. Jun 2011, 09:23
depends on the purpose. If you have a plain marquee, just call refresh or repaint on the dialog after each finished step.

If you need a clean animation without steps and the shiny animation from vista/7, you'll have to put your cpu heavy task into a thread.


Greets
Memnarch
Da man Trunc nicht auf einen Integer anwenden kann, muss dieser zuerst in eine Float kopiert werden
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#3

AW: Show dialog when processing data

  Alt 30. Jun 2011, 09:45
Code:
CreateThread
OnBeginThread ShowDialog
Run thread
OnEndThread CloseDialog
DestroyThread
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#4

Re: Show dialog when processing data

  Alt 30. Jun 2011, 14:02
Thanks guys. Depend on your advices I made this:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  JvThread1.Execute(Self);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if not JvThread1.Terminated then
    JvThread1.Terminate
  ;
end;

procedure TForm1.JvThread1Begin(Sender: TObject);
begin
  ProcessingDialog := TProcessingDialog.Create('Heavy Task');
  ProcessingDialog.Show;
end;

procedure TForm1.JvThread1CancelExecute(CurrentThread: TJvThread);
begin
  JvThread1Finish(Self);
end;

procedure TForm1.JvThread1Execute(Sender: TObject; Params: Pointer);
var
  I: Integer;
begin
  for I := 0 to 100000 do
  begin
    TForm1(Params).Value := I;
    JvThread1.Synchronize(TForm1(Params).UpdateStatus);

    if JvThread1.Terminated then
      Break
    ;
  end;
end;

procedure TForm1.JvThread1Finish(Sender: TObject);
begin
  ProcessingDialog.Free;
end;

procedure TForm1.UpdateStatus;
begin
  Caption := IntToStr(Value);
end;
Yes, I know, is completely lame, because uses component. But is simple

So, it working if I just open dialog, but I want to modal dialog (to lock access to interface), but when ShowModal(), thread don't execute. There is solution on this?
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.534 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: Show dialog when processing data

  Alt 30. Jun 2011, 14:05
Process your data within the modal dialog form.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:01 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz