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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
unit u_frmToolbar;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ExtCtrls, StdCtrls, u_ListView, u_frmMain;
type
TfrmToolbar = class(TForm)
popM_Permanent: TPopupMenu;
Options1: TMenuItem;
Gestiondesicones1: TMenuItem;
Aproposde1: TMenuItem;
Quitter1: TMenuItem;
popM_Category: TPopupMenu;
img_Left: TImage;
img_Right: TImage;
Gestiondesicones2: TMenuItem;
Modifiercettecatgorie1: TMenuItem;
Supprimercettecatgorie1: TMenuItem;
Affichercettecatgorie1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure Quitter1Click(Sender: TObject);
procedure OnClose(Sender: TObject; var Action: TCloseAction);
procedure CatClick(Sender: TObject);
private
l_deskView:cls_DeskView;
procedure DrawCategories;
public
//procedure CatClick(Sender: TObject);
{ Déclarations publiques }
end;
var
frmToolbar: TfrmToolbar;
implementation
uses u_Common, u_Xml;
{$R *.dfm}
procedure TfrmToolbar.FormCreate(Sender: TObject);
var
hProgman:THandle;
begin
//Chargement des parametres et icones
LoadSettings;
LoadIconDir(gSettings.IconDir);
DrawCategories; //Dessine les icones des catégories
//Pacement de la barre sur le bureau
Top:=5;
Left:=(screen.width div 2) - (Width div 2); //Barre centrée
{Affichage des icones du bureau}
l_deskView:=cls_DeskView.Create(self);
l_deskView.DrawListView;
l_deskView.DisplayCat(0);
//Affichage sur le bureau
//hProgman:= FindWindowEx(0,0,'Progman','Program Manager');
Windows.SetParent(self.Handle, l_deskView.Handle);
end;
procedure TfrmToolbar.OnClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmToolbar.Quitter1Click(Sender: TObject);
begin
if MessageDlg('Etes-vous sur de vouloir quiter ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
self.Close;
end;
{*Dessine les icones des différentes catégories*}
procedure TfrmToolbar.DrawCategories;
var
cPanel:TPanel;
cIcon:TImage;
cLabel:TLabel;
newLeft:integer;
ICat:integer;
begin
if high(global_Cats) = -1 then Exit; //Si il n'y a pas de categories, on sort
newLeft:=img_Left.Width+5;
for ICat := 0 to high(global_Cats) do
begin
cPanel:=TPanel.Create(self);
with cPanel do
begin
Parent:=self;
Caption:='';
PopupMenu:=popM_Category;
OnClick:=CatClick;
Top:=5;
Left:=newLeft;
Height:=self.Height-10;
Width:=Height;
newLeft:=newLeft+Width+10;
BevelKind:=bkFlat;
BevelOuter:=bvNone;
BevelInner:=bvNone;
Bringtofront;
end;
cIcon:=TImage.Create(cPanel);
with cIcon do
begin
PopupMenu:=popM_Category;
OnClick:=CatClick;
Parent:=cPanel;
Top:=0;
Left:=0;
Width:=cPanel.Width;
Height:=cPanel.Height-20;
Tag:=ICat; //Associe le numero de la catégorie a l'image
end;
cLabel:=TLabel.Create(cPanel);
with cLabel do
begin
PopupMenu:=popM_Category;
OnClick:=CatClick;
Parent:=cPanel;
AutoSize:=false;
Top:=cPAnel.Height-20;
Left:=3;
Width:=cPanel.Width-6;
Caption:=global_Cats[ICat].Name;
Alignment:=taCenter;
Tag:=ICat; //Associe le numero de la catégorie au label
end;
end;
end;
procedure TfrmToolbar.CatClick(Sender: TObject);
begin
showmessage('catclick');
if Sender is TImage then
l_deskView.DisplayCat((Sender as TImage).Tag)
else if Sender is TLabel then
l_deskView.DisplayCat((Sender as TLabel).Tag);
end;
end. |
Partager