diff --git a/.gitignore b/.gitignore index a9fd9e6..39ef3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ __history /Ex8/lib /Ex9/backup /Ex9/lib +/Ex10/backup +/Ex10/lib diff --git a/Ex10/Ex10ProjLaz.ico b/Ex10/Ex10ProjLaz.ico new file mode 100644 index 0000000..10c5fc1 Binary files /dev/null and b/Ex10/Ex10ProjLaz.ico differ diff --git a/Ex10/Ex10ProjLaz.lpi b/Ex10/Ex10ProjLaz.lpi new file mode 100644 index 0000000..81cee03 --- /dev/null +++ b/Ex10/Ex10ProjLaz.lpi @@ -0,0 +1,85 @@ + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="LCL"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="Ex10ProjLaz.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="Ex10Unit.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + </Unit> + <Unit> + <Filename Value="..\CommonUtils\MTUtils.pas"/> + <IsPartOfProject Value="True"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="Ex10ProjLaz"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <OtherUnitFiles Value="..\CommonUtils"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/Ex10/Ex10ProjLaz.lpr b/Ex10/Ex10ProjLaz.lpr new file mode 100644 index 0000000..ce9dc41 --- /dev/null +++ b/Ex10/Ex10ProjLaz.lpr @@ -0,0 +1,24 @@ +program Ex10ProjLaz; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX} + cthreads, + {$ENDIF} + {$IFDEF HASAMIGA} + athreads, + {$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, Ex10Unit, MTUtils; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/Ex10/Ex10ProjLaz.res b/Ex10/Ex10ProjLaz.res new file mode 100644 index 0000000..bb86af9 Binary files /dev/null and b/Ex10/Ex10ProjLaz.res differ diff --git a/Ex10/Ex10Unit.dfm b/Ex10/Ex10Unit.dfm index 6e94f61..9b704b0 100644 --- a/Ex10/Ex10Unit.dfm +++ b/Ex10/Ex10Unit.dfm @@ -69,7 +69,7 @@ object Form1: TForm1 object labPostMsgCount: TLabel Left = 212 Top = 118 - Width = 16 + Width = 7 Height = 16 Caption = '0' end diff --git a/Ex10/Ex10Unit.lfm b/Ex10/Ex10Unit.lfm new file mode 100644 index 0000000..197136a --- /dev/null +++ b/Ex10/Ex10Unit.lfm @@ -0,0 +1,116 @@ +object Form1: TForm1 + Left = 0 + Height = 181 + Top = 0 + Width = 452 + Caption = 'Form1' + ClientHeight = 181 + ClientWidth = 452 + Color = clBtnFace + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Tahoma' + OnDestroy = FormDestroy + Position = poScreenCenter + object Label1: TLabel + Left = 8 + Height = 16 + Top = 72 + Width = 64 + Caption = 'Результат:' + end + object labResult: TLabel + Left = 78 + Height = 16 + Top = 72 + Width = 7 + Caption = '0' + end + object Label2: TLabel + Left = 8 + Height = 16 + Top = 96 + Width = 119 + Caption = 'Статус вычислений:' + end + object labThreadStateInfo: TLabel + Left = 132 + Height = 16 + Top = 97 + Width = 18 + Caption = '???' + end + object Label3: TLabel + Left = 8 + Height = 16 + Top = 136 + Width = 243 + Caption = 'Число вызовов обработчика сообщения:' + end + object labPostMsgProcessCount: TLabel + Left = 257 + Height = 16 + Top = 136 + Width = 7 + Caption = '0' + end + object Label4: TLabel + Left = 8 + Height = 16 + Top = 118 + Width = 198 + Caption = 'Число отправленных сообщений:' + end + object labPostMsgCount: TLabel + Left = 212 + Height = 16 + Top = 118 + Width = 7 + Caption = '0' + end + object Label5: TLabel + Left = 8 + Height = 16 + Top = 157 + Width = 114 + Caption = 'Поток завершился:' + end + object labEndWork: TLabel + Left = 128 + Height = 16 + Top = 157 + Width = 18 + Caption = '???' + end + object btnRunInParallelThread: TButton + Left = 8 + Height = 33 + Top = 8 + Width = 217 + Caption = 'Вычислить сумму ряда чисел до:' + TabOrder = 0 + OnClick = btnRunInParallelThreadClick + end + object ProgressBar1: TProgressBar + Left = 8 + Height = 17 + Top = 49 + Width = 436 + Anchors = [akTop, akLeft, akRight] + TabOrder = 1 + end + object edMaxValue: TEdit + Left = 232 + Height = 24 + Top = 16 + Width = 89 + TabOrder = 2 + Text = '10000000' + end + object Timer1: TTimer + Interval = 100 + OnTimer = Timer1Timer + Left = 304 + Top = 120 + end +end diff --git a/Ex10/Ex10Unit.pas b/Ex10/Ex10Unit.pas index 7eb7afc..609fa58 100644 --- a/Ex10/Ex10Unit.pas +++ b/Ex10/Ex10Unit.pas @@ -1,10 +1,16 @@ -unit Ex10Unit; +{$IFDEF FPC}{$CODEPAGE UTF8}{$H+}{$MODE DELPHI}{$ENDIF} +unit Ex10Unit; interface uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, MTUtils, ComCtrls, ExtCtrls, StrUtils; + {$IFnDEF FPC} + Windows, Messages, + {$ELSE} + LCLIntf, LCLType, LMessages, {$IFDEF MSWINDOWS}Windows, Messages,{$ENDIF} + {$ENDIF} + SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, MTUtils, ComCtrls, + ExtCtrls, StrUtils; const UM_PROGRESS_CHANGE = WM_USER + 2; @@ -51,7 +57,7 @@ type { Private declarations } FMyThread: TMyThread; FPostMsgProcessCount: Integer; - procedure UMProgressChange(var Msg: TMessage); message UM_PROGRESS_CHANGE; + procedure UMProgressChange(var Msg: {$IFnDEF FPC}TMessage{$ELSE}TLMessage{$ENDIF}); message UM_PROGRESS_CHANGE; public { Public declarations } end; @@ -61,7 +67,11 @@ var PostMessageCount: Integer; implementation -{$R *.dfm} +{$IFnDEF FPC} + {$R *.dfm} +{$ELSE} + {$R *.lfm} +{$ENDIF} procedure TForm1.btnRunInParallelThreadClick(Sender: TObject); var @@ -96,7 +106,7 @@ begin labEndWork.Caption := IfThen(FMyThread.EndWork, 'ДА', 'НЕТ'); end; -procedure TForm1.UMProgressChange(var Msg: TMessage); +procedure TForm1.UMProgressChange(var Msg: {$IFnDEF FPC}TMessage{$ELSE}TLMessage{$ENDIF}); var ProgressData: TProgressData; begin