Skip to content

Commit 26f1d21

Browse files
authored
Merge pull request #188 from ReinierNL/update_demo33
Updates for demo 33
2 parents d9f3d58 + 2b1e619 commit 26f1d21

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

Demos/Demo33/ThSort.dfm

1.4 KB
Binary file not shown.

Demos/Demo33/ThSort.pas

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface
1212

1313
type
1414
TThreadSortForm = class(TForm)
15-
StartBtn: TButton;
15+
Start3Btn: TButton;
1616
BubbleSortBox: TPaintBox;
1717
SelectionSortBox: TPaintBox;
1818
QuickSortBox: TPaintBox;
@@ -25,23 +25,23 @@ TThreadSortForm = class(TForm)
2525
PythonMemo: TMemo;
2626
PythonEngine1: TPythonEngine;
2727
SortModule: TPythonModule;
28-
Start2Btn: TButton;
28+
Start1Btn: TButton;
2929
LoadBtn: TButton;
3030
PythonDialog: TOpenDialog;
3131
SaveDialog: TSaveDialog;
3232
SaveBtn: TButton;
33-
Button1: TButton;
33+
StopBtn: TButton;
3434
procedure BubbleSortBoxPaint(Sender: TObject);
3535
procedure SelectionSortBoxPaint(Sender: TObject);
3636
procedure QuickSortBoxPaint(Sender: TObject);
3737
procedure FormCreate(Sender: TObject);
38-
procedure StartBtnClick(Sender: TObject);
39-
procedure Start2BtnClick(Sender: TObject);
38+
procedure Start3BtnClick(Sender: TObject);
39+
procedure Start1BtnClick(Sender: TObject);
4040
procedure LoadBtnClick(Sender: TObject);
4141
procedure SaveBtnClick(Sender: TObject);
4242
procedure SortModuleInitialization(Sender: TObject);
4343
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
44-
procedure Button1Click(Sender: TObject);
44+
procedure StopBtnClick(Sender: TObject);
4545
private
4646
OwnThreadState: PPyThreadState;
4747
ThreadsRunning: Integer;
@@ -129,22 +129,22 @@ procedure TThreadSortForm.InitThreads(ThreadExecMode: TThreadExecMode; script: T
129129

130130
end;
131131

132-
StartBtn.Enabled := False;
133-
Start2Btn.Enabled := False;
132+
Start1Btn.Enabled := False;
133+
Start3Btn.Enabled := False;
134134
end;
135135

136-
procedure TThreadSortForm.Start2BtnClick(Sender: TObject);
136+
procedure TThreadSortForm.Start1BtnClick(Sender: TObject);
137137
begin
138138
with GetPythonEngine do
139139
begin
140140
ExecStrings(PythonMemo.Lines);
141-
self.InitThreads(emNewState,nil);
141+
self.InitThreads(emNewState, nil);
142142
end;
143143
end;
144144

145-
procedure TThreadSortForm.StartBtnClick(Sender: TObject);
145+
procedure TThreadSortForm.Start3BtnClick(Sender: TObject);
146146
begin
147-
InitThreads(emNewInterpreter,PythonMemo.Lines);
147+
InitThreads(emNewInterpreter, PythonMemo.Lines);
148148
//PythonEngine1.ExecStrings(PythonMemo.Lines);
149149
end;
150150

@@ -182,8 +182,8 @@ procedure TThreadSortForm.ThreadDone(Sender: TObject);
182182
if ThreadsRunning = 0 then
183183
begin
184184
GetPythonEngine.PyEval_RestoreThread(OwnThreadState);
185-
StartBtn.Enabled := True;
186-
Start2Btn.Enabled := True;
185+
Start1Btn.Enabled := True;
186+
Start3Btn.Enabled := True;
187187
ArraysRandom := False;
188188
Thread1 := nil;
189189
Thread2 := nil;
@@ -196,7 +196,8 @@ procedure TThreadSortForm.ThreadDone(Sender: TObject);
196196
}
197197

198198
function TThreadSortForm.SortModule_GetValue( pself, args : PPyObject ) : PPyObject; cdecl;
199-
var psort,index: integer;
199+
var
200+
psort, index: Integer;
200201
begin
201202
with GetPythonEngine do
202203
begin
@@ -208,12 +209,10 @@ function TThreadSortForm.SortModule_GetValue( pself, args : PPyObject ) : PPyObj
208209
end;
209210
end;
210211

211-
212-
213212
function TThreadSortForm.SortModule_Swap( pself, args : PPyObject ) : PPyObject; cdecl;
214-
var psort,i,j: integer;
213+
var
214+
psort, i, j: Integer;
215215
begin
216-
217216
with GetPythonEngine do
218217
begin
219218
if (PyErr_Occurred() = nil) and (PyArg_ParseTuple( args, 'iii',@psort, @i, @j) <> 0) then
@@ -225,8 +224,6 @@ function TThreadSortForm.SortModule_Swap( pself, args : PPyObject ) : PPyObject;
225224
end;
226225
end;
227226

228-
229-
230227
procedure TThreadSortForm.SortModuleInitialization(Sender: TObject);
231228
begin
232229
with Sender as TPythonModule do
@@ -240,7 +237,7 @@ procedure TThreadSortForm.SortModuleInitialization(Sender: TObject);
240237
end;
241238
end;
242239

243-
procedure TThreadSortForm.Button1Click(Sender: TObject);
240+
procedure TThreadSortForm.StopBtnClick(Sender: TObject);
244241
begin
245242
if Assigned(Thread1) and not Thread1.Finished then Thread1.Stop();
246243
if Assigned(Thread2) and not Thread2.Finished then Thread2.Stop();

Demos/Demo33/ThrdDemo2.dproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
7979
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
8080
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
81+
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
8182
</PropertyGroup>
8283
<PropertyGroup Condition="'$(Base_Win64)'!=''">
8384
<Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
@@ -90,6 +91,7 @@
9091
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
9192
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
9293
<VerInfo_Locale>1033</VerInfo_Locale>
94+
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
9395
</PropertyGroup>
9496
<PropertyGroup Condition="'$(Cfg_1)'!=''">
9597
<Version>7.0</Version>

0 commit comments

Comments
 (0)