unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ShellApi, StdCtrls, ExtCtrls, IkonaZasobnika, Menus, AppEvnts;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    CheckBox1: TCheckBox;
    PopupMenu1: TPopupMenu;
    Helion1: TMenuItem;
    Delphi20051: TMenuItem;
    JacekMatulewski1: TMenuItem;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure CheckBox1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    iz :TIkonaZasobnika;
    procedure UkryjOkno(Sender :TObject);
    procedure PokazInformacje(Sender :TObject);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
if iz=nil then
  begin
  iz:=TIkonaZasobnika.Create(Self);
  iz.Parent:=Self;
  iz.Icon.LoadFromFile('Ikona.ico');
  iz.Hint:='Helion';

  iz.PopupMenu:=PopupMenu1;
  iz.OnClick:=UkryjOkno;
  iz.OnDblClick:=PokazInformacje;

  CheckBox1.Checked:=True;
  CheckBox1.Enabled:=True;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if iz<>nil then
  begin
  iz.Free;
  iz:=nil;
  CheckBox1.Enabled:=False;
  end;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if iz=nil then Exit;
iz.Visible:=CheckBox1.Checked;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Button2Click(Self);
end;

procedure TForm1.UkryjOkno(Sender :TObject);
begin
Visible:=not Visible;
end;

procedure TForm1.PokazInformacje(Sender :TObject);
begin
FlashWindow(Application.Handle,True);
ShowMessage('Delphi 2005. 303 praktyczne przykłady');
end;

end.
