unit Unit1;
interface
uses
...
const WM_TASKBAREVENT = WM_USER + 1;
type
TForm1 =
class(TForm)
...
procedure TaskBarAddIcon(add:boolean);
procedure TaskBarRemoveIcon;
procedure FormShow(Sender: TObject);
...
private
procedure WMTASKBAREVENT(
var message: TMessage);
message WM_TASKBAREVENT;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure Tform1.Starter;
BEGIN
...
TaskBarAddIcon(true);
...
END;
//-------- Button im Contextmenü des Formulars um
// die Form entweder fsNormal, oder fsStayOnTop festzulegen -----------------
procedure TForm1.On1Click(Sender: TObject);
begin
if form1.On1.Checked
then
BEGIN
form1.FormStyle := fsNormal;
form1.On1.Checked := false;
END else
BEGIN
form1.FormStyle := fsStayOnTop;
form1.On1.Checked := true;
END;
end;
procedure TForm1.Beenden1Click(Sender: TObject);
begin
TaskBarRemoveIcon;
Application.Terminate;
end;
//----------Für Taskicon----------
procedure TForm1.WMTASKBAREVENT(
var message: TMessage);
VAR
MousePos: TPOINT;
begin
case message.LParamLo
of
WM_LBUTTONDOWN :
BEGIN
end;
WM_RBUTTONDOWN :
begin
IconPop.Popup(MousePos.x, MousePos.y);
end;
WM_LBUTTONDBLCLK :
begin
end;
end;
end;
procedure Tform1.TaskBarAddIcon(add:boolean);
var
tnid: TNOTIFYICONDATA;
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;
end;
strcopy(tnid.szTip,'
ADAM');
if add
then
Shell_NotifyIcon(NIM_ADD, @tnid)
else
Shell_NotifyIcon(NIM_MODIFY, @tnid)
end;
procedure TForm1.TaskBarRemoveIcon;
var
tnid: TNOTIFYICONDATA ;
begin
tnid.cbSize := sizeof(TNOTIFYICONDATA);
tnid.Wnd := Form1.handle;
tnid.uID := 1;
Shell_NotifyIcon(NIM_DELETE, @tnid);
end;
procedure TForm1.FormShow(Sender: TObject);
var
Owner: HWnd;
begin
Owner := GetWindow(Form1.Handle,GW_OWNER);
If Owner<>0
Then
ShowWindow(Owner,SW_HIDE);
end;
//-------- Button im Contextmenü des TrayIcons -----------------
procedure TForm1.OnlineCheck1Click(Sender: TObject);
begin
Application.ShowMainForm := true;
Form1.Show;
end;
...