PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/popupnotifier/unit1.pas

http://github.com/graemeg/lazarus
Pascal | 72 lines | 51 code | 15 blank | 6 comment | 0 complexity | e1e11e8b0070c5557c7a5218594e1d7d MD5 | raw file
 1unit unit1;
 2
 3{$mode objfpc}{$H+}
 4
 5interface
 6
 7uses
 8  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
 9  popupnotifier, Buttons, StdCtrls;
10
11type
12
13  { TForm1 }
14
15  TForm1 = class(TForm)
16    Button1: TButton;
17    Button2: TButton;
18    Edit1: TEdit;
19    Memo1: TMemo;
20    PopupNotifier1: TPopupNotifier;
21    procedure Button1Click(Sender: TObject);
22    procedure Button2Click(Sender: TObject);
23    procedure PopupNotifier1Close(Sender: TObject; var CloseAction: TCloseAction);
24  private
25    { private declarations }
26  public
27    { public declarations }
28  end; 
29
30var
31  Form1: TForm1; 
32
33implementation
34
35{$R unit1.lfm}
36
37{ TForm1 }
38
39procedure TForm1.Button1Click(Sender: TObject);
40begin
41  If PopupNotifier1.Visible then
42   Begin
43        PopupNotifier1.Hide;
44        Button1.Caption := 'Show Popup';
45   end else
46   begin
47        PopupNotifier1.ShowAtPos(100,100);
48        Button1.Caption := 'Hide Popup';
49   end;
50end;
51
52procedure TForm1.Button2Click(Sender: TObject);
53Var I : Integer;
54begin
55  PopupNotifier1.Text := '';
56  PopupNotifier1.Title := Edit1.Text;
57  If Memo1.Lines.Count > 0 then
58  Begin
59       PopupNotifier1.Text := Memo1.Lines[0];
60         For I := 1 to Memo1.Lines.Count -1 do
61         PopupNotifier1.Text := PopupNotifier1.Text+LineEnding+Memo1.Lines[I];
62  end;
63end;
64
65procedure TForm1.PopupNotifier1Close(Sender: TObject;
66  var CloseAction: TCloseAction);
67begin
68  Button1.Caption := 'Show Popup';
69end;
70
71end.
72