ini buat yg belum tao and yg uda tao
Code:
uses
..., ShellAPI;
const
WM_ICONTRAY = WM_USER + 1; //User-defined message
type
...
var
...
NotifyIconData : TNotifyIconData;
implementation
procedure Tform1.formcreate(sender:Tobject);
begin
with NotifyIconData do
begin
hIcon := Icon.Handle;
StrPCopy(szTip, Application.Title);
Wnd := Handle;
uCallbackMassage := WM_ICONTRAY;
uID := 1;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
cbSize := sizeof(TNotifyIconData);
end;
shell_NotifyIconData(NIM_ADD,@NotifyIconData);
{ini bisa ditaruh di onMinimize ato yg lainnya yg diatas juga heheh...}
SetWindowLong(
Application.Handle,
GWL_EXSTYLE,
WS_EX_TOOLWINDOW);
end;
-code diatas digunakan untuk memunculkan icon pada objectinspector Form1
-tambahkan popupmenu untuk listing code dibawah ini
-jangan lupa icon nya dikasih gambar yah... kalo nga nti binggung...
Code:
type
TForm1 = class(TForm)
....
private
{ Private declarations }
....
procedure Icontray(
var Msg: Tmessage); message WM_ICONTRAY;
public
{ Public declarations }
...
end;
procedure Tform1.Icontray(var Msg : Tmessage);
var
CursorPos : Tpoint;
begin
if Msg.LParam = WM_RBUTTONDOWN then
begin
GetCursorPos(CursorPos);
PopupMenu1.Popup(CursorPos.X, CursorPos.Y);
end else
inherited;
end;
-menampilkan dan menyembunyikan form
-tambahkan Exit dan Show pada item di popupmenu
Code:
procedure TForm1.Show1Click(Sender: TObject);
begin
Application.Restore;
// Shell_NotifyIcon(NIM_DELETE,@NotifyIconData);
end;
procedure Tform1.FormClose(
Sender : TObject;
var Action : TCloseAction);
begin
Action := caNone;
Hide;
//Shell_NotifyIcon(NIM_ADD,@NotifyIcaonData);
end;
Procedure TForm1.Exit1Click(sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NotifyIconData);
Application.ProcessManager;
Application.Terminate;
end;
pertanyaannya...
-pada even show1click aku menggunakana Application.Restore karena
pada saat aku menggunakan Form1.Show; tidak terjadi apa2...
-kira2 kenapa yah?
- ada code yg lain buat nampilin form nya nga ?
- Thanks
- Selamat Mencoba |