unit Unit1;
// Anmeldung
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ShellApi, Mask,XPMan,
DB, DBTables,
OleCtrls,DateUtils, SHDocVw,INIFiles, jpeg, AppEvnts;
const
WM_TASKBAREVENT = WM_USER + 1;
type
TForm1 =
class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Minimize(Sender: TObject);
private
procedure WMTaskbarEvent(
var Message: TMessage);
message WM_TASKBAREVENT;
procedure TaskBarRemoveIcon;
procedure TaskBarAddIcon;
public
end;
var
Form1: TForm1;
implementation
uses
{$R *.dfm}
procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
TaskBarAddIcon;
end;
procedure TForm1.TaskBarAddIcon;
var
tnid: TNotifyIconData;
Owner: HWnd;
begin
with tnid
do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := Form1.Handle;
uID := 1;
uFlags := NIF_MESSAGE
or NIF_ICON
or NIF_TIP;
uCallbackMessage := WM_TASKBAREVENT;
hIcon := Application.Icon.Handle;
PostMessage(Application.Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
StrCopy(tnid.szTip, '
Runterfahren');
Shell_NotifyIcon(NIM_ADD, @tnid);
Owner:=GetWindow(Form1.Handle,GW_OWNER);
If Owner<>0
then
ShowWindow(Owner,SW_HIDE);
end;
procedure TForm1.TaskBarRemoveIcon;
var
tnid: TNotifyIconData;
Owner: HWnd;
begin
tnid.cbSize := SizeOf(TNotifyIconData);
tnid.Wnd := Form1.Handle;
tnid.uID := 1;
Shell_NotifyIcon(NIM_DELETE, @tnid);
Owner:=GetWindow(Form1.Handle,GW_OWNER);
If Owner<>0
then
begin
ShowWindow(Owner,SW_Show);
ShowWindow(Owner,SW_Normal);
end;
end;
procedure TForm1.WMTaskbarEvent(
var Message: TMessage);
var
Point: TPoint;
begin
case Message.LParamLo
of
WM_LBUTTONDOWN: TaskBarRemoveIcon;
WM_RBUTTONDOWN:
begin
SetForegroundWindow(
Handle);
GetCursorPos(point);
end;
end;
end;
end.