From: Jens F. <jfu...@us...> - 2004-12-06 23:36:18
|
Update of /cvsroot/jvcl/dev/JVCL3/examples/JvThread In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24697/JVCL3/examples/JvThread Modified Files: fThread.dfm fThread.pas Log Message: TJvThread enhanced, now it's possible to show a dialog while the thread is executed. Two sample dialogs included At designtime TJvThread is moved to the Toolbar Jv Threading Index: fThread.dfm =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/examples/JvThread/fThread.dfm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fThread.dfm 19 Feb 2004 22:47:40 -0000 1.3 --- fThread.dfm 6 Dec 2004 23:36:06 -0000 1.4 *************** *** 1,10 **** object Form1: TForm1 ! Left = 353 ! Top = 149 BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'JvThread Demo' ! ClientHeight = 99 ! ClientWidth = 243 Color = clBtnFace DefaultMonitor = dmDesktop --- 1,10 ---- object Form1: TForm1 ! Left = 397 ! Top = 361 BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'JvThread Demo' ! ClientHeight = 452 ! ClientWidth = 719 Color = clBtnFace DefaultMonitor = dmDesktop *************** *** 21,26 **** TextHeight = 13 object Label1: TLabel ! Left = 132 ! Top = 24 Width = 50 Height = 13 --- 21,26 ---- TextHeight = 13 object Label1: TLabel ! Left = 67 ! Top = 49 Width = 50 Height = 13 *************** *** 28,39 **** end object Label2: TLabel ! Left = 200 ! Top = 24 Width = 3 Height = 13 end object Label3: TLabel ! Left = 132 ! Top = 58 Width = 50 Height = 13 --- 28,39 ---- end object Label2: TLabel ! Left = 135 ! Top = 49 Width = 3 Height = 13 end object Label3: TLabel ! Left = 67 ! Top = 103 Width = 50 Height = 13 *************** *** 41,46 **** end object Label4: TLabel ! Left = 200 ! Top = 58 Width = 3 Height = 13 --- 41,46 ---- end object Label4: TLabel ! Left = 135 ! Top = 103 Width = 3 Height = 13 *************** *** 51,55 **** Width = 75 Height = 25 ! Caption = 'Start Job 1' TabOrder = 0 OnClick = Button1Click --- 51,55 ---- Width = 75 Height = 25 ! Caption = 'Start Job &1' TabOrder = 0 OnClick = Button1Click *************** *** 57,67 **** object Button2: TButton Left = 36 ! Top = 54 Width = 75 Height = 25 ! Caption = 'Start Job 2' TabOrder = 1 OnClick = Button2Click end object JvThread1: TJvThread Exclusive = True --- 57,85 ---- object Button2: TButton Left = 36 ! Top = 69 Width = 75 Height = 25 ! Caption = 'Start Job &2' TabOrder = 1 OnClick = Button2Click end + object Button3: TButton + Left = 121 + Top = 18 + Width = 100 + Height = 25 + Caption = 'Start Job 1 &Dialog' + TabOrder = 2 + OnClick = Button3Click + end + object Button4: TButton + Left = 121 + Top = 69 + Width = 100 + Height = 25 + Caption = 'Start Job 2 D&ialog' + TabOrder = 3 + OnClick = Button4Click + end object JvThread1: TJvThread Exclusive = True *************** *** 69,72 **** --- 87,91 ---- FreeOnTerminate = False OnExecute = JvThread1Execute + ThreadDialog = JvThreadSimpleDialog1 Left = 6 Top = 6 *************** *** 77,82 **** --- 96,119 ---- FreeOnTerminate = False OnExecute = JvThread2Execute + ThreadDialog = JvThreadAnimateDialog1 Left = 6 Top = 44 end + object JvThreadSimpleDialog1: TJvThreadSimpleDialog + DialogOptions.ShowDialog = True + DialogOptions.InfoText = 'Infotext' + DialogOptions.Caption = '23423423423432' + DialogOptions.CancelButtonCaption = 'Cancel' + Left = 260 + Top = 20 + end + object JvThreadAnimateDialog1: TJvThreadAnimateDialog + DialogOptions.ShowDialog = True + DialogOptions.InfoText = 'Info' + DialogOptions.Caption = 'Execute Thread' + DialogOptions.CancelButtonCaption = 'Cancel' + DialogOptions.CommonAVI = aviCopyFiles + Left = 255 + Top = 70 + end end Index: fThread.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/examples/JvThread/fThread.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fThread.pas 19 Feb 2004 22:47:40 -0000 1.4 --- fThread.pas 6 Dec 2004 23:36:06 -0000 1.5 *************** *** 31,35 **** uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, JvThread, JvComponent; type --- 31,35 ---- uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, JvThread, JvComponent, JvThreadDialog, ComCtrls; type *************** *** 43,46 **** --- 43,50 ---- Label4: TLabel; Button2: TButton; + JvThreadSimpleDialog1: TJvThreadSimpleDialog; + JvThreadAnimateDialog1: TJvThreadAnimateDialog; + Button3: TButton; + Button4: TButton; procedure JvThread1Execute(Sender: TObject; params: Pointer); procedure Button1Click(Sender: TObject); *************** *** 48,51 **** --- 52,57 ---- procedure Button2Click(Sender: TObject); procedure FormDestroy(Sender: TObject); + procedure Button4Click(Sender: TObject); + procedure Button3Click(Sender: TObject); private public *************** *** 93,97 **** begin Inc(k,5); //This is the only difference with the other thread ! //To use global variable/objects, you have to synchronize (to avoid conflicts) TForm1(params).Value2 := k; --- 99,103 ---- begin Inc(k,5); //This is the only difference with the other thread ! sleep(13); //To use global variable/objects, you have to synchronize (to avoid conflicts) TForm1(params).Value2 := k; *************** *** 105,108 **** --- 111,115 ---- procedure TForm1.Button1Click(Sender: TObject); begin + JvThread1.ThreadDialog := Nil; JvThread1.Execute(Self); (Sender as TButton).Enabled := False; *************** *** 111,114 **** --- 118,122 ---- procedure TForm1.Button2Click(Sender: TObject); begin + JvThread2.ThreadDialog := Nil; JvThread2.Execute(Self); (Sender as TButton).Enabled := False; *************** *** 139,141 **** --- 147,163 ---- end; + procedure TForm1.Button4Click(Sender: TObject); + begin + JvThread2.ThreadDialog := JvThreadAnimateDialog1; + JvThread2.Execute(Self); + (Sender as TButton).Enabled := False; + end; + + procedure TForm1.Button3Click(Sender: TObject); + begin + JvThread1.ThreadDialog := JvThreadSimpleDialog1; + JvThread1.Execute(Self); + (Sender as TButton).Enabled := False; + end; + end. |