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
| unit HeaderFooterTemplate;
interface
uses
{$IFDEF MSWINDOWS}
vcl.ExtCtrls, vcl.Menus, FMX.Objects, {$ENDIF}
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
System.Actions, FMX.ActnList;
type
THeaderFooterForm = class(TForm)
Header: TToolBar;
Footer: TToolBar;
HeaderLabel: TLabel;
ActionList1: TActionList;
Action1: TAction;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
{$IFDEF MSWINDOWS}procedure TrayIcon1DblClick(Sender: TObject); {$ENDIF}
procedure Action1Execute(Sender: TObject);
private
{$IFDEF MSWINDOWS}TrayIcon1 : TTrayIcon;
MonPopup : TPopupMenu;
MenuItem : TMenuItem;
{$ENDIF}
public
{ Public declarations }
end;
var
HeaderFooterForm: THeaderFooterForm;
implementation
{$R *.fmx}
procedure THeaderFooterForm.Action1Execute(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
TrayIcon1.Hint := 'Action 1 !';
{$ENDIF}
end;
procedure THeaderFooterForm.FormCreate(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
TrayIcon1 := TTrayIcon.Create(self);
MonPopup := vcl.Menus.TPopupMenu.Create(self);
MenuItem := vcl.Menus.TMenuItem.Create(self);
{$ENDIF}
end;
procedure THeaderFooterForm.FormDestroy(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
TrayIcon1.Free;
MonPopup.Free;
{$ENDIF}
end;
procedure THeaderFooterForm.FormShow(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
MenuItem.Caption := Action1.Text;
MenuItem.Action := Action1;
MonPopup.Items.Add(MenuItem);
TrayIcon1.PopupMenu := MonPopup;
TrayIcon1.Hint := 'Ca fonctionne !';
TrayIcon1.OnDblClick := TrayIcon1DblClick;
TrayIcon1.Visible := True;
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
procedure THeaderFooterForm.TrayIcon1DblClick(Sender: TObject);
begin
// double clic
TrayIcon1.Visible := False;
end;
{$ENDIF}
end. |
Partager