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
| unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
imglist48: TImageList;
imglist16: TImageList;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormActivate(Sender: TObject);
var
idx: integer;
s: string;
ico: TBitmap; // TIcon ça foire, go figure...
bsuccess: boolean;
procedure WorkWithNoParam;
begin
image2.Visible:=True;
end;
procedure suite;
begin
ico := TBitmap.Create;
ico.Width:=16; ico.Height:=16;
imglist48.GetBitmap(idx, image1.Picture.Bitmap);
imglist16.GetBitmap(idx, ico);
application.Icon.Assign(ico);
form1.Icon.Assign(ico);
ico.Free;
end;
procedure WorkWithOneParam;
begin
bsuccess := TryStrToInt(application.Params[1], idx);// index de l'icône et sa validation
if bsuccess then suite else s := application.Params[1];
end;
procedure WorkWithMultiParam;
var
i,appliParamCount: integer;
begin
appliParamCount := application.ParamCount;
bsuccess := TryStrToInt(application.Params[appliParamCount], idx);// index de l'icône et sa validation
if idx > imglist48.Count-1 then idx := 0; // 'tite sécurité
if bsuccess then begin
dec(appliParamCount);
suite;
end;
form1.Caption := application.Params[1]; // titre
// texte
s := '';
for i := 2 to appliParamCount do
s := s + application.Params[i] + ' ';
end;
begin
// si multimot(s), à protéger par double quote
// icône en dernier
// 0 = pas de param (c'est idiot, --> help)
// 1 = un seul param, au milieu, mais c'est idiot aussi
// x = 2 ou + --> le premier est le titre de la fiche,
// et le dernier si numérique est l'index de l'icône dans l'imglist
s := 'Pas de paramètre(s) passé(s) -----> rien à afficher. ' +
'Note : le dernier param = idx de l''icône si numérique (0 à 4).';
case application.ParamCount of
0: WorkWithNoParam;
1: WorkWithOneParam;
else WorkWithMultiParam;
end;
label1.Caption := s;
end;
end. |
Partager