unit FBUnit;

{next version:
  - corrected example (added call to DestroyIcon)
}

interface

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

type
  TForm1 = class(TForm)
    FlatSpeedButton1: TFlatSpeedButton;
    FlatButton1: TFlatButton;
    FlatButton2: TFlatButton;
    PopupMenu1: TPopupMenu;
    FirstMenuItem1: TMenuItem;
    SecondMenuItem1: TMenuItem;
    Menu1: TMenuItem;
    Label1: TLabel;
    FlatButton3: TFlatButton;
    procedure FormCreate(Sender: TObject);
    procedure FlatSpeedButton1MenuShow(Sender: TObject);
    procedure FlatSpeedButton1MenuHide(Sender: TObject);
    procedure FlatButton1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
  SH:TSHFileInfo;
begin
  SHGetFileInfo(PChar(Application.ExeName),0,sh,SizeOf(TSHFileInfo),
     SHGFI_ICON OR SHGFI_SHELLICONSIZE);
  FlatSpeedButton1.Icon:=SH.hIcon;
  FlatSpeedButton1.IconWidth:=32;
  FlatSpeedButton1.IconHeight:=32;
    {Width and Height must be specified otherwise button won't be
     painted correctly}
end;

procedure TForm1.FlatSpeedButton1MenuShow(Sender: TObject);
begin
  Label1.Show;
end;

procedure TForm1.FlatSpeedButton1MenuHide(Sender: TObject);
begin
  Label1.Hide;
end;

procedure TForm1.FlatButton1Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DestroyIcon (FlatSpeedButton1.Icon);
end;

end.
