summaryrefslogtreecommitdiff
path: root/plugins/Chess4Net/InfoUnit.pas
blob: f4b349a71dc3dab22bc8e539ff9180ebce9eadcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
////////////////////////////////////////////////////////////////////////////////
// All code below is exclusively owned by author of Chess4Net - Pavel Perminov
// (packpaul@mail.ru, packpaul1@gmail.com).
// Any changes, modifications, borrowing and adaptation are a subject for
// explicit permition from the owner.

unit InfoUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellAPI;

type
  TInfoForm = class(TForm)
    OkButton: TButton;
    PluginNameLabel: TLabel;
    PlayingViaLabel: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    URLLabel: TLabel;
    EMailLabel: TLabel;
    procedure OkButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure EMailLabelClick(Sender: TObject);
    procedure URLLabelClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  end;

procedure ShowInfo;

implementation

{$R *.dfm}

uses
  GlobalsLocalUnit, ModalForm;

var
  infoForm: TInfoForm = nil;

procedure ShowInfo;
begin
  if (not Assigned(infoForm)) then
  begin
    infoForm := TInfoForm.Create(nil);
    if (TDialogs.HasStayOnTopOwners) then
      infoForm.FormStyle := fsStayOnTop;
{$IFDEF SKYPE}
    infoForm.Icon := Chess4NetIcon;
    infoForm.Caption := DIALOG_CAPTION;      
{$ELSE} // MI, TRILLIAN, AND_RQ, QIP
    infoForm.Icon := pluginIcon;
    infoForm.Caption := PLUGIN_NAME;
{$ENDIF}
  end;
  if not infoForm.Showing then
    infoForm.Show
  else
    infoForm.SetFocus;
end;

procedure TInfoForm.OkButtonClick(Sender: TObject);
begin
  Close;
end;

procedure TInfoForm.FormCreate(Sender: TObject);
begin
  PlayingViaLabel.Caption := PLUGIN_PLAYING_OVER; 
  PluginNameLabel.Caption := PLUGIN_INFO_NAME;
  URLLabel.Caption := PLUGIN_URL;
  EMailLabel.Caption := PLUGIN_EMAIL;
end;

procedure TInfoForm.URLLabelClick(Sender: TObject);
begin
  ShellExecute(Handle, nil, PChar(URLLabel.Caption), nil, nil, SW_SHOWNORMAL);
end;

procedure TInfoForm.EMailLabelClick(Sender: TObject);
var
  shellStr: string;
begin
  shellStr := 'mailto:' + EMailLabel.Caption;
  ShellExecute(Handle, nil, PChar(shellStr), nil, nil, SW_SHOWNORMAL);
end;

procedure TInfoForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  infoForm := nil;
  Action := caFree;
end;

end.