/examples/popupnotifier/unit1.pas

http://github.com/graemeg/lazarus · Pascal · 72 lines · 51 code · 15 blank · 6 comment · 0 complexity · e1e11e8b0070c5557c7a5218594e1d7d MD5 · raw file

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