Réponse acceptée !
Je sortie le code de la source voilà ce que ça donne
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,ShellApi,
Dialogs, StdCtrls, Menus;
Const
wm_AppelMessage = wm_user+1;
WM_CallBackMessage = WM_USER + 1;
NIF_INFO = $10;
NIIF_INFO = $00000001;
type
PNewNotifyIconData = ^TNewNotifyIconData;
TDUMMYUNIONNAME = Record
Case Integer Of
0: (uTimeout: UINT);
1: (uVersion: UINT);
End;
TNewNotifyIconData = Record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
//Version 5.0 is 128 chars, old ver is 64 chars
szTip: Array [0..127] of Char;
dwState: DWORD; //Version 5.0
dwStateMask: DWORD; //Version 5.0
szInfo: Array [0..255] Of Char; //Version 5.0
DUMMYUNIONNAME: TDUMMYUNIONNAME;
szInfoTitle: Array [0..63] Of Char; //Version 5.0
dwInfoFlags: DWORD; //Version 5.0
End;
type
TForm1 = class(TForm)
Button1: TButton;
PopupMenu1: TPopupMenu;
Quitter1: TMenuItem;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Quitter1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Déclarations privées }
procedure WMAppelMessage(var msg : TMessage); message wm_AppelMessage; //tray
Procedure AfficheBulleTips;
Procedure SupprimeSysTrayIcone;
Procedure AjouteSysTrayIcone;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
nid :TNewNotifyIconData; //Tray Icône
implementation
{$R *.dfm}
//----------------------------------------------------------------------------//
// Appel commande icone du Tray //
//----------------------------------------------------------------------------//
procedure TForm1.WMAppelMessage(var msg : TMessage);
Var Curs:TPoint;
begin
//Si Clique droit de la souris
if msg.LParam=Wm_RButtonDown then
begin
SetForegroundWindow(Handle);
GetCursorPos(Curs); //Récupère les coordonnées de la souris
PopupMenu1.Popup(Curs.X,Curs.Y); //Ouvre le menu surgissant à l'emplacement spécfié par les coordonnees de la souris
PostMessage(Handle,WM_NULL,0,0);
end;
end;
//----------------------------------------------------------------------------//
// Affiche une bulle pour informer //
//----------------------------------------------------------------------------//
Procedure TForm1.AfficheBulleTips;
Var
TipsInfo, TipsTitre: String;
begin
nid.cbSize := SizeOf(nid);
nid.uFlags := NIF_INFO;
TipsInfo := 'Le Hook du Calendrier est activé.';
strPLCopy(nid.szInfo, TipsInfo, SizeOf(nid.szInfo) - 1);
nid.DUMMYUNIONNAME.uTimeout := 3000;
TipsTitre := 'Surveillance du Bureau';
strPLCopy(nid.szInfoTitle, TipsTitre, SizeOf(nid.szInfoTitle) - 1);
// Symbole affiché dans la bulle
// NIIF_INFO --> Bulle i
// NIIF_ERROR --> Croix x rouge
// NIIF_WARNING --> Triangle Jaune
nid.dwInfoFlags := NIIF_INFO; //NIIF_ERROR;//NIIF_WARNING;
Shell_NotifyIcon(NIM_MODIFY, @nid);
end;
//----------------------------------------------------------------------------//
// Ajoute l'icone de l'application dans la barre de Notification //
//----------------------------------------------------------------------------//
Procedure TForm1.AjouteSysTrayIcone;
Begin
nid.cbSize := SizeOf(nid);
nid.Wnd := Handle ;
nid.uID := 0;
nid.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
nid.uCallbackMessage := WM_CallBackMessage;
nid.hIcon := Application.Icon.Handle;
// Message du Hint
strPLCopy(nid.sztip,'Essai info bulle' , SizeOf(nid.sztip) - 1);
Shell_NotifyIcon(NIM_ADD, @nid);
end;
//----------------------------------------------------------------------------//
// Supprime l'icone de l'application dans la barre de Notification //
//----------------------------------------------------------------------------//
Procedure TForm1.SupprimeSysTrayIcone;
Begin
Shell_NotifyIcon(Nim_DELETE,@nid); //Supprime le tray icon
End;
procedure TForm1.FormCreate(Sender: TObject);
begin
AjouteSysTrayIcone;
end;
procedure TForm1.Quitter1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.btn1Click(Sender: TObject);
Begin
AfficheBulleTips;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SupprimeSysTrayIcone;
end;
end.
Bon code 