unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellApi;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
IconData: TNotifyIconData;
public
{ Public-Deklarationen }
procedure WndProc(
var Msg: TMessage);
override;
procedure WMSysCommand(
var Message: TWMSysCommand);
message WM_SYSCOMMAND;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//Icon neben Uhr anzeigen
//Icon beim beenden "zerstören"
procedure TfrmSysInfo.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @IconData);
end;
//belegung der Maustaten
procedure TfrmSysInfo.WndProc(
var Msg: TMessage);
var
Point: TPoint;
begin
if Msg.Msg = WM_USER + 20
then begin
case Msg.lParam
of
WM_RBUTTONDOWN:
begin
GetCursorPos(Point);
PopUpMenu1.PopUp(Point.X, Point.Y);
end;
WM_LBUTTONDOWN:
begin
frmInfo.ShowModal;
end;
WM_LBUTTONUP:
begin
frmInfo.Modalresult := 1;
end;
end;
end;
inherited;
end;
//Form nach mimimieren nicht in Taskleiste anzeigen
procedure TfrmSysInfo.WMSysCommand(
var Message: TWMSysCommand);
begin
if Message.CmdType
AND $FFF0 = SC_MINIMIZE
then
Hide
else
inherited;
end;
//???
procedure TfrmSysInfo.FormShow(Sender: TObject);
var
Owner: hWnd;
begin
Owner := GetWindow(
Handle, GW_OWNER);
ShowWindow(Owner, SW_HIDE);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.ShowMainForm := False;
//Programm gar nicht erst anzeigen
IconData.cbSize := SizeOf(IconData);
IconData.Wnd :=
Handle;
IconData.uID := 100;
IconData.uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
IconData.uCallBackMessage := WM_USER + 20;
IconData.hIcon := Application.Icon.Handle;
IconData.szTip := '
SysInfo';
Shell_NotifyIcon(NIM_ADD, @IconData);
// fügt das Icon ein
end;
end.