![]() |
Delphi-Version: 2010
Show dialog when processing data
Here is pseudocode which demonstrate what I want to tell:
Delphi-Quellcode:
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?
CreateAndShowDialog();
MakeSomeTaskWhichNeedManyCPUTime() DestroyDialog(); |
AW: Show dialog when processing data
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 |
AW: Show dialog when processing data
Code:
CreateThread
OnBeginThread ShowDialog Run thread OnEndThread CloseDialog DestroyThread |
Re: Show dialog when processing data
Thanks guys. Depend on your advices I made this:
Delphi-Quellcode:
Yes, I know, is completely lame, because uses component. But is simple :D
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; 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? |
AW: Show dialog when processing data
Process your data within the modal dialog form.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:25 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz