program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Unit1.pas
unit Unit1;
//Exemple sur l'utilisation des hints dans les applications delphi
//Marchioni Valérian - loub1@caramail.com - icq#: 30687888
//09/04/2002
//Exemple librement redistribuable dans un but éducatif et non commercial
//Le source peut être modifié et redistribué à condition de fournir l'original
//et de conserver les informations sur les auteurs
//Les hints : principe de fonctionnement:
//Les composants visuels ont pour la plupart les propriétés Hint et ShowHint
// -ShowHint est boolean et Hint est de type string
// -Hint peut contenir 2 informations: le ShortHint et le LongHint
// Les deux valeurs sont séparées par une barre verticale (|)
// Ex.: 'Voici le short|Voici le long'
// 'Ici, uniquement un short'
// Pour récupérer l'une ou l'autre de ces 2 informations, on a 2 functions:
// GetShortHint et GetLongHint
//Le comportement des hints se définit dans l'objet Application.
//On y définit:
// -La procédure à exécuter lorsqu'un événement Hint est généré (onHint)
// -La couleur de fond des info-bulles
// -Les différentes tempos des info-bulles
//Lorsqu'un événement onHint est généré, la string du hint est stockée dans Application.Hint;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Shape1: TShape;
Label1: TLabel;
CheckBox1: TCheckBox;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Shape2: TShape;
Label5: TLabel;
ColorDialog1: TColorDialog;
Edit3: TEdit;
StatusBar1: TStatusBar;
UpDown1: TUpDown;
Label6: TLabel;
Edit4: TEdit;
UpDown2: TUpDown;
Label7: TLabel;
procedure CheckBox1Click(Sender: TObject);
procedure Shape2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
procedure GestionHints(sender:TObject);
procedure MiseAJour;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.GestionHints(sender:TObject);
begin
StatusBar1.SimpleText:=GetLongHint(Application.Hint)
end;
procedure TForm1.MiseAJour;
begin
if edit2.text<>'' then
begin
Label1.Hint:=edit1.text+'|'+edit2.text;
Shape1.hint:=edit1.text+'|'+edit2.text;
end else
begin
Label1.Hint:=edit1.text;
Shape1.hint:=edit1.text;
end;
label4.caption:='Valeur de la propriété hint: '+label1.Hint;
Application.HintHidePause:=updown1.Position*1000;
Application.HintPause:=UpDown2.Position*1000;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
Shape1.ShowHint:=CheckBox1.Checked;
label1.ShowHint:=CheckBox1.Checked;
end;
procedure TForm1.Shape2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
begin
ColorDialog1.Color:=Application.HintColor;
if ColorDialog1.Execute then
begin
Application.HintColor:=ColorDialog1.Color;
Shape2.Brush.Color:=ColorDialog1.Color;
end;
end;
procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
MiseAJour;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnHint:=GestionHints;
MiseAJour;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
MiseAJour;
end;
end.

