rendered paste bodyunit oefenopdr;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, ImgList;
type
TmainForm = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure TrayMessage(var Msg:TMessage);
private
icon1 : TIcon;
trayicondata: TNotifyIconData;
{ Private declarations }
public
{ Public declarations }
end;
const wm_icontray = wm_user + 1;
var
mainForm: TmainForm;
implementation
{$R *.dfm}
procedure TmainForm.FormCreate(Sender: TObject);
begin
with trayIconData do
begin
cbSize := SizeOf(trayicondata);
Wnd := classes.AllocateHWnd(TrayMessage);
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := WM_ICONTRAY;
StrPCopy(szTip, Application.Title);
szTip := 'Een eenvoudige system tray applicatie';
Application.ShowMainForm := false;
end;
icon1:=Ticon.Create;
icon1.LoadFromFile('C:\Program Files\Stardock\Object Desktop\WindowBlinds\url\ip.ico');
TrayIconData.hIcon := icon1.Handle;
Shell_NotifyIcon(NIM_MODIFY, @TrayIconData);
end;
procedure TmainForm.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @TrayIconData);
end;
procedure TmainForm.TrayMessage(var Msg:TMessage);
begin
case Msg.LParam of
WM_LBUTTONDOWN:
begin
showMessage('Linker muisknop ingedrukt: let"s show the Form!');
MainForm.Show;
end;
WM_RBUTTONDOWN:
begin
Showmessage('Rechter muisknop ingedrukt: let"s hide the form!');
MainForm.Hide;
end;
end;
end;
end.