+ added process demo
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
05d331486c
commit
f9b38ed18f
71
examples/process/processdemo.lpi
Normal file
71
examples/process/processdemo.lpi
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="5"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<IconPath Value="./"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
</General>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<DestinationDirectory Value="$(ProjPath)\published\"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="FCL"/>
|
||||
<MinVersion Major="1" Valid="True"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="processdemo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ProcessDemo"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="processdemomainform.pas"/>
|
||||
<ComponentName Value="MultipleProcessDemoForm"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ResourceFilename Value="processdemomainform.lrs"/>
|
||||
<UnitName Value="ProcessDemoMainForm"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<SrcPath Value="$(LazarusDir)\lcl\;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType)\"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
15
examples/process/processdemo.lpr
Normal file
15
examples/process/processdemo.lpr
Normal file
@ -0,0 +1,15 @@
|
||||
program ProcessDemo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ add your units here }, ProcessDemoMainForm;
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMultipleProcessDemoForm,MultipleProcessDemoForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
254
examples/process/processdemomainform.lfm
Normal file
254
examples/process/processdemomainform.lfm
Normal file
@ -0,0 +1,254 @@
|
||||
object MultipleProcessDemoForm: TMultipleProcessDemoForm
|
||||
Left = 334
|
||||
Height = 502
|
||||
Top = 179
|
||||
Width = 630
|
||||
HorzScrollBar.Page = 629
|
||||
VertScrollBar.Page = 501
|
||||
ActiveControl = CloseButton
|
||||
Caption = 'Demo of using multple processes'
|
||||
OnClose = MultipleProcessDemoFormClose
|
||||
object CloseButton: TButton
|
||||
Left = 288
|
||||
Height = 25
|
||||
Top = 464
|
||||
Width = 75
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Close'
|
||||
OnClick = CloseButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object ProcessPanel: TPanel
|
||||
Left = 8
|
||||
Height = 438
|
||||
Top = 8
|
||||
Width = 614
|
||||
Align = alClient
|
||||
BorderSpacing.Bottom = 48
|
||||
BorderSpacing.Around = 8
|
||||
BevelOuter = bvNone
|
||||
FullRepaint = False
|
||||
TabOrder = 1
|
||||
object Process1GroupBox1: TGroupBox
|
||||
Height = 438
|
||||
Width = 315
|
||||
Align = alLeft
|
||||
Caption = 'Process 1'
|
||||
TabOrder = 0
|
||||
object Process1InputLabel: TLabel
|
||||
AnchorSideTop.Control = CommandLine1LabeledEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 17
|
||||
Top = 48
|
||||
Width = 65
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Input'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object Process1OutputLabel1: TLabel
|
||||
AnchorSideTop.Control = Process1InputMemo
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 17
|
||||
Top = 184
|
||||
Width = 65
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Output'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object CommandLine1LabeledEdit: TLabeledEdit
|
||||
Left = 8
|
||||
Height = 24
|
||||
Top = 16
|
||||
Width = 289
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 5
|
||||
BorderSpacing.Right = 5
|
||||
EditLabel.Left = 8
|
||||
EditLabel.Height = 17
|
||||
EditLabel.Top = -4
|
||||
EditLabel.Width = 80
|
||||
EditLabel.Caption = 'CommandLine'
|
||||
EditLabel.Color = clNone
|
||||
EditLabel.ParentColor = False
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
Text = '"C:\Program Files\PuTTY\plink.exe" yourputtysessionname'
|
||||
end
|
||||
object Process1SendInputButton: TButton
|
||||
AnchorSideTop.Control = Process1InputMemo
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 222
|
||||
Height = 25
|
||||
Top = 176
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Send Input'
|
||||
OnClick = ProcessSendInputButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Process1StartButton: TButton
|
||||
AnchorSideTop.Control = CommandLine1LabeledEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 222
|
||||
Height = 25
|
||||
Top = 40
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Start'
|
||||
OnClick = ProcessStartButtonClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object Process1InputMemo: TMemo
|
||||
AnchorSideTop.Control = Process1InputLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 103
|
||||
Top = 73
|
||||
Width = 291
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 8
|
||||
TabOrder = 1
|
||||
end
|
||||
object Process1OutputMemo: TMemo
|
||||
AnchorSideTop.Control = Process1OutputLabel1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 199
|
||||
Top = 209
|
||||
Width = 289
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 8
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 4
|
||||
WordWrap = False
|
||||
end
|
||||
end
|
||||
object ProcessSplitter: TSplitter
|
||||
Left = 315
|
||||
Height = 438
|
||||
Width = 5
|
||||
end
|
||||
object Process2GroupBox: TGroupBox
|
||||
Left = 320
|
||||
Height = 438
|
||||
Width = 294
|
||||
Align = alClient
|
||||
Caption = 'Process 2'
|
||||
TabOrder = 1
|
||||
object Process2InputLabel: TLabel
|
||||
AnchorSideTop.Control = CommandLine1LabeledEdit
|
||||
Left = 6
|
||||
Height = 17
|
||||
Top = 48
|
||||
Width = 65
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Input'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object Process2OutputLabel: TLabel
|
||||
AnchorSideTop.Control = Process1InputMemo
|
||||
Left = 8
|
||||
Height = 17
|
||||
Top = 184
|
||||
Width = 65
|
||||
BorderSpacing.Top = 8
|
||||
Caption = 'Output'
|
||||
Color = clNone
|
||||
ParentColor = False
|
||||
end
|
||||
object CommandLine2LabeledEdit: TLabeledEdit
|
||||
Left = 8
|
||||
Height = 24
|
||||
Top = 16
|
||||
Width = 268
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 5
|
||||
BorderSpacing.Right = 5
|
||||
EditLabel.Left = 8
|
||||
EditLabel.Height = 17
|
||||
EditLabel.Top = -4
|
||||
EditLabel.Width = 80
|
||||
EditLabel.Caption = 'CommandLine'
|
||||
EditLabel.Color = clNone
|
||||
EditLabel.ParentColor = False
|
||||
ParentColor = False
|
||||
TabOrder = 0
|
||||
Text = '"C:\Program Files\PuTTY\plink.exe" yourputtysessionname'
|
||||
end
|
||||
object Process2SendInputButton: TButton
|
||||
AnchorSideTop.Control = Process1InputMemo
|
||||
Left = 201
|
||||
Height = 25
|
||||
Top = 176
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Send Input'
|
||||
OnClick = ProcessSendInputButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Process2StartButton: TButton
|
||||
AnchorSideTop.Control = CommandLine1LabeledEdit
|
||||
Left = 201
|
||||
Height = 25
|
||||
Top = 40
|
||||
Width = 75
|
||||
Anchors = [akTop, akRight]
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Start'
|
||||
OnClick = ProcessStartButtonClick
|
||||
TabOrder = 3
|
||||
end
|
||||
object Process2InputMemo: TMemo
|
||||
AnchorSideTop.Control = Process1InputLabel
|
||||
Left = 6
|
||||
Height = 103
|
||||
Top = 73
|
||||
Width = 270
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 8
|
||||
TabOrder = 1
|
||||
end
|
||||
object Process2OutputMemo: TMemo
|
||||
AnchorSideTop.Control = Process1OutputLabel1
|
||||
Left = 8
|
||||
Height = 199
|
||||
Top = 209
|
||||
Width = 268
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 8
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 4
|
||||
WordWrap = False
|
||||
end
|
||||
end
|
||||
end
|
||||
object Process1: TProcess
|
||||
Options = [poUsePipes, poStderrToOutPut, poNoConsole]
|
||||
Priority = ppNormal
|
||||
left = 456
|
||||
top = 8
|
||||
end
|
||||
object ReadOutputIdleTimer: TIdleTimer
|
||||
Interval = 100
|
||||
OnTimer = ReadOutputIdleTimerTimer
|
||||
left = 456
|
||||
top = 152
|
||||
end
|
||||
object Process2: TProcess
|
||||
Options = [poUsePipes, poStderrToOutPut, poNoConsole]
|
||||
Priority = ppNormal
|
||||
left = 456
|
||||
top = 72
|
||||
end
|
||||
end
|
85
examples/process/processdemomainform.lrs
Normal file
85
examples/process/processdemomainform.lrs
Normal file
@ -0,0 +1,85 @@
|
||||
{ This is an automatically generated lazarus resource file }
|
||||
|
||||
LazarusResources.Add('TMultipleProcessDemoForm','FORMDATA',[
|
||||
'TPF0'#24'TMultipleProcessDemoForm'#23'MultipleProcessDemoForm'#4'Left'#3'N'#1
|
||||
+#6'Height'#3#246#1#3'Top'#3#179#0#5'Width'#3'v'#2#18'HorzScrollBar.Page'#3'u'
|
||||
+#2#18'VertScrollBar.Page'#3#245#1#13'ActiveControl'#7#11'CloseButton'#7'Capt'
|
||||
+'ion'#6#31'Demo of using multple processes'#7'OnClose'#7#28'MultipleProcessD'
|
||||
+'emoFormClose'#0#7'TButton'#11'CloseButton'#4'Left'#3' '#1#6'Height'#2#25#3
|
||||
+'Top'#3#208#1#5'Width'#2'K'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#25'BorderS'
|
||||
+'pacing.InnerBorder'#2#4#7'Caption'#6#5'Close'#7'OnClick'#7#16'CloseButtonCl'
|
||||
+'ick'#8'TabOrder'#2#0#0#0#6'TPanel'#12'ProcessPanel'#4'Left'#2#8#6'Height'#3
|
||||
+#182#1#3'Top'#2#8#5'Width'#3'f'#2#5'Align'#7#8'alClient'#20'BorderSpacing.Bo'
|
||||
+'ttom'#2'0'#20'BorderSpacing.Around'#2#8#10'BevelOuter'#7#6'bvNone'#11'FullR'
|
||||
+'epaint'#8#8'TabOrder'#2#1#0#9'TGroupBox'#17'Process1GroupBox1'#6'Height'#3
|
||||
+#182#1#5'Width'#3';'#1#5'Align'#7#6'alLeft'#7'Caption'#6#9'Process 1'#8'TabO'
|
||||
+'rder'#2#0#0#6'TLabel'#18'Process1InputLabel'#21'AnchorSideTop.Control'#7#23
|
||||
+'CommandLine1LabeledEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6
|
||||
+'Height'#2#17#3'Top'#2'0'#5'Width'#2'A'#17'BorderSpacing.Top'#2#8#7'Caption'
|
||||
+#6#5'Input'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#6'TLabel'#20'Process1'
|
||||
+'OutputLabel1'#21'AnchorSideTop.Control'#7#17'Process1InputMemo'#18'AnchorSi'
|
||||
+'deTop.Side'#7#9'asrBottom'#4'Left'#2#8#6'Height'#2#17#3'Top'#3#184#0#5'Widt'
|
||||
+'h'#2'A'#17'BorderSpacing.Top'#2#8#7'Caption'#6#6'Output'#5'Color'#7#6'clNon'
|
||||
+'e'#11'ParentColor'#8#0#0#12'TLabeledEdit'#23'CommandLine1LabeledEdit'#4'Lef'
|
||||
+'t'#2#8#6'Height'#2#24#3'Top'#2#16#5'Width'#3'!'#1#7'Anchors'#11#5'akTop'#6
|
||||
+'akLeft'#7'akRight'#0#8'AutoSize'#9#18'BorderSpacing.Left'#2#5#19'BorderSpac'
|
||||
+'ing.Right'#2#5#14'EditLabel.Left'#2#8#16'EditLabel.Height'#2#17#13'EditLabe'
|
||||
+'l.Top'#2#252#15'EditLabel.Width'#2'P'#17'EditLabel.Caption'#6#11'CommandLin'
|
||||
+'e'#15'EditLabel.Color'#7#6'clNone'#21'EditLabel.ParentColor'#8#11'ParentCol'
|
||||
+'or'#8#8'TabOrder'#2#0#4'Text'#6'7"C:\Program Files\PuTTY\plink.exe" yourput'
|
||||
+'tysessionname'#0#0#7'TButton'#23'Process1SendInputButton'#21'AnchorSideTop.'
|
||||
+'Control'#7#17'Process1InputMemo'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Le'
|
||||
+'ft'#3#222#0#6'Height'#2#25#3'Top'#3#176#0#5'Width'#2'K'#7'Anchors'#11#5'akT'
|
||||
+'op'#7'akRight'#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#10'Send Inp'
|
||||
+'ut'#7'OnClick'#7#27'ProcessSendInputButtonClick'#8'TabOrder'#2#2#0#0#7'TBut'
|
||||
+'ton'#19'Process1StartButton'#21'AnchorSideTop.Control'#7#23'CommandLine1Lab'
|
||||
+'eledEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#3#222#0#6'Height'#2
|
||||
+#25#3'Top'#2'('#5'Width'#2'K'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderS'
|
||||
+'pacing.InnerBorder'#2#4#7'Caption'#6#5'Start'#7'OnClick'#7#23'ProcessStartB'
|
||||
+'uttonClick'#8'TabOrder'#2#3#0#0#5'TMemo'#17'Process1InputMemo'#21'AnchorSid'
|
||||
+'eTop.Control'#7#18'Process1InputLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'
|
||||
+#4'Left'#2#6#6'Height'#2'g'#3'Top'#2'I'#5'Width'#3'#'#1#7'Anchors'#11#5'akTo'
|
||||
+'p'#6'akLeft'#7'akRight'#0#17'BorderSpacing.Top'#2#8#8'TabOrder'#2#1#0#0#5'T'
|
||||
+'Memo'#18'Process1OutputMemo'#21'AnchorSideTop.Control'#7#20'Process1OutputL'
|
||||
+'abel1'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#8#6'Height'#3#199#0#3
|
||||
+'Top'#3#209#0#5'Width'#3'!'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8
|
||||
+'akBottom'#0#17'BorderSpacing.Top'#2#8#10'ScrollBars'#7#6'ssBoth'#8'TabOrder'
|
||||
+#2#4#8'WordWrap'#8#0#0#0#9'TSplitter'#15'ProcessSplitter'#4'Left'#3';'#1#6'H'
|
||||
+'eight'#3#182#1#5'Width'#2#5#0#0#9'TGroupBox'#16'Process2GroupBox'#4'Left'#3
|
||||
+'@'#1#6'Height'#3#182#1#5'Width'#3'&'#1#5'Align'#7#8'alClient'#7'Caption'#6#9
|
||||
+'Process 2'#8'TabOrder'#2#1#0#6'TLabel'#18'Process2InputLabel'#21'AnchorSide'
|
||||
+'Top.Control'#7#23'CommandLine1LabeledEdit'#4'Left'#2#6#6'Height'#2#17#3'Top'
|
||||
+#2'0'#5'Width'#2'A'#17'BorderSpacing.Top'#2#8#7'Caption'#6#5'Input'#5'Color'
|
||||
+#7#6'clNone'#11'ParentColor'#8#0#0#6'TLabel'#19'Process2OutputLabel'#21'Anch'
|
||||
+'orSideTop.Control'#7#17'Process1InputMemo'#4'Left'#2#8#6'Height'#2#17#3'Top'
|
||||
+#3#184#0#5'Width'#2'A'#17'BorderSpacing.Top'#2#8#7'Caption'#6#6'Output'#5'Co'
|
||||
+'lor'#7#6'clNone'#11'ParentColor'#8#0#0#12'TLabeledEdit'#23'CommandLine2Labe'
|
||||
+'ledEdit'#4'Left'#2#8#6'Height'#2#24#3'Top'#2#16#5'Width'#3#12#1#7'Anchors'
|
||||
+#11#5'akTop'#6'akLeft'#7'akRight'#0#8'AutoSize'#9#18'BorderSpacing.Left'#2#5
|
||||
+#19'BorderSpacing.Right'#2#5#14'EditLabel.Left'#2#8#16'EditLabel.Height'#2#17
|
||||
+#13'EditLabel.Top'#2#252#15'EditLabel.Width'#2'P'#17'EditLabel.Caption'#6#11
|
||||
+'CommandLine'#15'EditLabel.Color'#7#6'clNone'#21'EditLabel.ParentColor'#8#11
|
||||
+'ParentColor'#8#8'TabOrder'#2#0#4'Text'#6'7"C:\Program Files\PuTTY\plink.exe'
|
||||
+'" yourputtysessionname'#0#0#7'TButton'#23'Process2SendInputButton'#21'Ancho'
|
||||
+'rSideTop.Control'#7#17'Process1InputMemo'#4'Left'#3#201#0#6'Height'#2#25#3
|
||||
+'Top'#3#176#0#5'Width'#2'K'#7'Anchors'#11#5'akTop'#7'akRight'#0#25'BorderSpa'
|
||||
+'cing.InnerBorder'#2#4#7'Caption'#6#10'Send Input'#7'OnClick'#7#27'ProcessSe'
|
||||
+'ndInputButtonClick'#8'TabOrder'#2#2#0#0#7'TButton'#19'Process2StartButton'
|
||||
,#21'AnchorSideTop.Control'#7#23'CommandLine1LabeledEdit'#4'Left'#3#201#0#6'H'
|
||||
+'eight'#2#25#3'Top'#2'('#5'Width'#2'K'#7'Anchors'#11#5'akTop'#7'akRight'#0#25
|
||||
+'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#5'Start'#7'OnClick'#7#23'Proces'
|
||||
+'sStartButtonClick'#8'TabOrder'#2#3#0#0#5'TMemo'#17'Process2InputMemo'#21'An'
|
||||
+'chorSideTop.Control'#7#18'Process1InputLabel'#4'Left'#2#6#6'Height'#2'g'#3
|
||||
+'Top'#2'I'#5'Width'#3#14#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#17
|
||||
+'BorderSpacing.Top'#2#8#8'TabOrder'#2#1#0#0#5'TMemo'#18'Process2OutputMemo'
|
||||
+#21'AnchorSideTop.Control'#7#20'Process1OutputLabel1'#4'Left'#2#8#6'Height'#3
|
||||
+#199#0#3'Top'#3#209#0#5'Width'#3#12#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akR'
|
||||
+'ight'#8'akBottom'#0#17'BorderSpacing.Top'#2#8#10'ScrollBars'#7#6'ssBoth'#8
|
||||
+'TabOrder'#2#4#8'WordWrap'#8#0#0#0#0#8'TProcess'#8'Process1'#7'Options'#11#10
|
||||
+'poUsePipes'#16'poStderrToOutPut'#11'poNoConsole'#0#8'Priority'#7#8'ppNormal'
|
||||
+#4'left'#3#200#1#3'top'#2#8#0#0#10'TIdleTimer'#19'ReadOutputIdleTimer'#8'Int'
|
||||
+'erval'#2'd'#7'OnTimer'#7#24'ReadOutputIdleTimerTimer'#4'left'#3#200#1#3'top'
|
||||
+#3#152#0#0#0#8'TProcess'#8'Process2'#7'Options'#11#10'poUsePipes'#16'poStder'
|
||||
+'rToOutPut'#11'poNoConsole'#0#8'Priority'#7#8'ppNormal'#4'left'#3#200#1#3'to'
|
||||
+'p'#2'H'#0#0#0
|
||||
]);
|
157
examples/process/processdemomainform.pas
Normal file
157
examples/process/processdemomainform.pas
Normal file
@ -0,0 +1,157 @@
|
||||
unit ProcessDemoMainForm;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
|
||||
StdCtrls, ExtCtrls, Process, LCLProc, ComCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TMultipleProcessDemoForm }
|
||||
|
||||
TMultipleProcessDemoForm = class(TForm)
|
||||
Process2:TProcess;
|
||||
Process2GroupBox:TGroupBox;
|
||||
Process2InputLabel:TLabel;
|
||||
Process2InputMemo:TMemo;
|
||||
Process2OutputLabel:TLabel;
|
||||
Process2OutputMemo:TMemo;
|
||||
Process2SendInputButton:TButton;
|
||||
Process2StartButton:TButton;
|
||||
CommandLine2LabeledEdit:TLabeledEdit;
|
||||
ReadOutputIdleTimer:TIdleTimer;
|
||||
Process1:TProcess;
|
||||
Process1SendInputButton:TButton;
|
||||
Process1StartButton:TButton;
|
||||
CloseButton:TButton;
|
||||
CommandLine1LabeledEdit:TLabeledEdit;
|
||||
Process1InputLabel:TLabel;
|
||||
Process1OutputLabel1:TLabel;
|
||||
Process1InputMemo:TMemo;
|
||||
Process1GroupBox1:TGroupBox;
|
||||
Process1OutputMemo:TMemo;
|
||||
ProcessPanel:TPanel;
|
||||
ProcessSplitter:TSplitter;
|
||||
StatusBar1:TStatusBar;
|
||||
procedure CloseButtonClick(Sender:TObject);
|
||||
procedure MultipleProcessDemoFormClose(Sender:TObject;
|
||||
var CloseAction:TCloseAction);
|
||||
procedure ProcessSendInputButtonClick(Sender:TObject);
|
||||
procedure ProcessStartButtonClick(Sender:TObject);
|
||||
procedure ReadOutputIdleTimerTimer(Sender:TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
procedure StartProcess(Process: TProcess; StartButton: TButton;
|
||||
const CommandLine: string);
|
||||
procedure SendInput(Process: TProcess; InputMemo: TMemo);
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
MultipleProcessDemoForm: TMultipleProcessDemoForm;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$ifdef win32}
|
||||
windows;
|
||||
{$else}
|
||||
baseunix, unix;
|
||||
{$endif}
|
||||
|
||||
{ TMultipleProcessDemoForm }
|
||||
|
||||
procedure TMultipleProcessDemoForm.CloseButtonClick(Sender:TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TMultipleProcessDemoForm.MultipleProcessDemoFormClose(Sender:TObject;
|
||||
var CloseAction:TCloseAction);
|
||||
begin
|
||||
if Process1.Running then
|
||||
Process1.Terminate(0);
|
||||
if Process2.Running then
|
||||
Process2.Terminate(0);
|
||||
end;
|
||||
|
||||
procedure TMultipleProcessDemoForm.ProcessSendInputButtonClick(Sender:TObject);
|
||||
begin
|
||||
if Sender=Process1SendInputButton then
|
||||
SendInput(Process1, Process1InputMemo);
|
||||
if Sender=Process2SendInputButton then
|
||||
SendInput(Process2, Process2InputMemo);
|
||||
end;
|
||||
|
||||
procedure TMultipleProcessDemoForm.ProcessStartButtonClick(Sender:TObject);
|
||||
begin
|
||||
if Sender=Process1StartButton then
|
||||
StartProcess(Process1, Process1StartButton, CommandLine1LabeledEdit.Text);
|
||||
if Sender=Process2StartButton then
|
||||
StartProcess(Process2, Process2StartButton, CommandLine2LabeledEdit.Text);
|
||||
end;
|
||||
|
||||
procedure TMultipleProcessDemoForm.ReadOutputIdleTimerTimer(Sender:TObject);
|
||||
var
|
||||
NoMoreOutput: boolean;
|
||||
|
||||
procedure DoStuffForProcess(Process: TProcess; StartButton: TButton;
|
||||
OutputMemo: TMemo);
|
||||
var
|
||||
TotalBytesAvailable: integer;
|
||||
Buffer: string;
|
||||
BytesRead:LongInt;
|
||||
begin
|
||||
if not StartButton.Enabled then
|
||||
StartButton.Enabled := not Process.Running;
|
||||
if Process.Running then begin
|
||||
Windows.PeekNamedPipe(Process.Output.Handle, nil, 0, nil,
|
||||
@TotalBytesAvailable, nil);
|
||||
while TotalBytesAvailable>0 do begin
|
||||
SetLength(Buffer, TotalBytesAvailable);
|
||||
BytesRead := Process.OutPut.Read(Buffer[1], TotalBytesAvailable);
|
||||
OutputMemo.Text := OutputMemo.Text + copy(Buffer,1, BytesRead);
|
||||
Windows.PeekNamedPipe(Process.Output.Handle, nil, 0, nil,
|
||||
@TotalBytesAvailable, nil);
|
||||
NoMoreOutput := false;
|
||||
end;
|
||||
OutputMemo.SelStart := Length(OutputMemo.Text);
|
||||
end;
|
||||
end;
|
||||
begin
|
||||
repeat
|
||||
NoMoreOutput := true;
|
||||
DoStuffForProcess(Process1, Process1StartButton, Process1OutputMemo);
|
||||
DoStuffForProcess(Process2, Process2StartButton, Process2OutputMemo);
|
||||
until noMoreOutput;
|
||||
end;
|
||||
|
||||
procedure TMultipleProcessDemoForm.StartProcess(Process:TProcess;
|
||||
StartButton: TButton; const CommandLine: string);
|
||||
begin
|
||||
if not Process.Running then begin
|
||||
StartButton.Enabled := false;
|
||||
Process.CommandLine := CommandLine;
|
||||
Process.Execute;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMultipleProcessDemoForm.SendInput(Process:TProcess;InputMemo:TMemo);
|
||||
var
|
||||
InputStrings: string;
|
||||
begin
|
||||
if Process.Running then begin
|
||||
InputStrings := InputMemo.Lines.Text;
|
||||
Process.Input.Write(InputStrings[1], length(InputStrings));
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I processdemomainform.lrs}
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user