Стартовый пул
This commit is contained in:
58
UniqueInstance/testcomponent/fmain.lfm
Normal file
58
UniqueInstance/testcomponent/fmain.lfm
Normal file
@@ -0,0 +1,58 @@
|
||||
object Form1: TForm1
|
||||
Left = 464
|
||||
Height = 280
|
||||
Top = 339
|
||||
Width = 340
|
||||
HorzScrollBar.Page = 339
|
||||
VertScrollBar.Page = 279
|
||||
ActiveControl = ListBox1
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Test UniqueInstance'
|
||||
ClientHeight = 280
|
||||
ClientWidth = 340
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.7'
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Height = 15
|
||||
Top = 8
|
||||
Width = 145
|
||||
Caption = 'Waiting for new instances...'
|
||||
ParentColor = False
|
||||
end
|
||||
object ListBox1: TListBox
|
||||
Left = 8
|
||||
Height = 216
|
||||
Top = 24
|
||||
Width = 320
|
||||
ItemHeight = 0
|
||||
TabOrder = 0
|
||||
end
|
||||
object CrashAppButton: TButton
|
||||
Left = 8
|
||||
Height = 25
|
||||
Top = 248
|
||||
Width = 136
|
||||
BorderSpacing.InnerBorder = 4
|
||||
Caption = 'Crash Application'
|
||||
OnClick = CrashAppButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object ShowDialogButton: TButton
|
||||
Left = 192
|
||||
Height = 25
|
||||
Top = 248
|
||||
Width = 136
|
||||
Caption = 'Show Dialog'
|
||||
OnClick = ShowDialogButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object UniqueInstance1: TUniqueInstance
|
||||
Enabled = True
|
||||
Identifier = 'test0.1'
|
||||
UpdateInterval = 800
|
||||
OnOtherInstance = UniqueInstance1OtherInstance
|
||||
left = 152
|
||||
top = 104
|
||||
end
|
||||
end
|
81
UniqueInstance/testcomponent/fmain.pas
Normal file
81
UniqueInstance/testcomponent/fmain.pas
Normal file
@@ -0,0 +1,81 @@
|
||||
unit fMain;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
UniqueInstance, StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
CrashAppButton: TButton;
|
||||
ShowDialogButton: TButton;
|
||||
Label1: TLabel;
|
||||
ListBox1: TListBox;
|
||||
UniqueInstance1: TUniqueInstance;
|
||||
procedure CrashAppButtonClick(Sender: TObject);
|
||||
procedure ShowDialogButtonClick(Sender: TObject);
|
||||
procedure UniqueInstance1OtherInstance(Sender: TObject; Count: Integer;
|
||||
Parameters: array of String);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$ifdef unix}
|
||||
uses
|
||||
BaseUnix;
|
||||
{$endif}
|
||||
|
||||
{$ifdef windows}
|
||||
uses
|
||||
Windows;
|
||||
{$endif}
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.UniqueInstance1OtherInstance(Sender: TObject; Count: Integer;
|
||||
Parameters: array of String);
|
||||
var
|
||||
i:Integer;
|
||||
begin
|
||||
Label1.Caption:=Format('A new instance was created at %s with %d parameter(s):', [TimeToStr(Time), Count]);
|
||||
ListBox1.Clear;
|
||||
for i := 0 to Count - 1 do
|
||||
ListBox1.Items.Add(Parameters[i]);
|
||||
BringToFront;
|
||||
//hack to force app bring to front
|
||||
FormStyle := fsSystemStayOnTop;
|
||||
FormStyle := fsNormal;
|
||||
end;
|
||||
|
||||
procedure TForm1.CrashAppButtonClick(Sender: TObject);
|
||||
begin
|
||||
{$ifdef unix}
|
||||
FpKill(FpGetpid, 9);
|
||||
{$endif}
|
||||
{$ifdef windows}
|
||||
TerminateProcess(GetCurrentProcess, 0);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TForm1.ShowDialogButtonClick(Sender: TObject);
|
||||
begin
|
||||
Application.MessageBox('Hi! I am a modal Window!', 'Modal Window Check', MB_ICONINFORMATION);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
78
UniqueInstance/testcomponent/testinstance.lpi
Normal file
78
UniqueInstance/testcomponent/testinstance.lpi
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="UniqueInstanceTest"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<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="uniqueinstance_package"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="testinstance.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="fmain.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="fMain"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="TestInstance"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="C:\bin\code\fpc302rc1\bin\i386-win32\fpc.exe"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
21
UniqueInstance/testcomponent/testinstance.lpr
Normal file
21
UniqueInstance/testcomponent/testinstance.lpr
Normal file
@@ -0,0 +1,21 @@
|
||||
program testinstance;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ add your units here }, fMain;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Title := 'UniqueInstanceTest';
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
Reference in New Issue
Block a user