18. august 2003 - 16:13
Der er
8 kommentarer og
1 løsning
minimer program
hej jeg er igang med en media player. men vil have lavet sådan at når man f.eks trykker på en button knap så kommer den til at ligge nede i menuen med ur'et..
Kan nogen hjælpe med det
/////Snokey
Slettet bruger
18. august 2003 - 17:18
#9
unit UnitTrayIcon;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Menus, ShellAPi, AppEvnts, StdCtrls;
const
wm_IconMessage = wm_User;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
Details1: TMenuItem;
Close1: TMenuItem;
N1: TMenuItem;
About1: TMenuItem;
Button1: TButton;
procedure Details1Click(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
public
nid: TNotifyIconData;
Procedure InitializeNID;
procedure IconTray (var Msg: TMessage); message wm_IconMessage;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Procedure TForm1.InitializeNID;
begin
ShowWindow(Application.Handle, SW_HIDE);
Icon.Handle := LoadIcon (HInstance, 'MAINICON');
nid.cbSize := sizeof (nid);
nid.wnd := Handle;
nid.uID := 1; // icon ID
nid.uCallBAckMessage := wm_IconMessage;
nid.hIcon := Icon.Handle;
nid.uFlags := nif_Message or nif_Icon or nif_Tip;
strcopy (nid.szTip, PChar('Et lille HINT'));
Shell_NotifyIcon (NIM_ADD, @nid);
end;
procedure TForm1.IconTray (var msg: TMessage);
var
Pt: TPoint;
begin
if Msg.lParam = wm_rbuttondown then
begin
GetCursorPos (Pt);
PopupMenu1.Popup (Pt.x, Pt.y);
end;
if Msg.lParam = wm_lbuttondblclk then
Details1Click (self);
end;
procedure TForm1.Details1Click(Sender: TObject);
begin
nid.uFlags := 0;
Shell_NotifyIcon (NIM_DELETE, @nid);
//Application.Restore;
ShowWindow (Handle, sw_ShowNormal);
SetForegroundWindow (Handle);
Show;
end;
procedure TForm1.Close1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
nid.uFlags := 0;
Shell_NotifyIcon (NIM_DELETE, @nid);
end;
procedure TForm1.About1Click(Sender: TObject);
begin
MessageDlg ('Notify Icon Data Demo' + #13+ ' - By Jens Borrisholt' + #13 + ' © 1998', mtInformation, [mbOk], 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
InitializeNID;
ShowWindow (Handle, SW_HIDE);
end;
end.