Arsip: Menempatkan Icon dalam System Tray


by marvel in Articles more 18 years ago 2620
Skrip-skrip berikut digunakan untuk menempatkan ikon di SystemTray, sorry kalo masih ada kesalahan2 pada koding ini
uses
..., ShellAPI;
const
WM_ICONTRAY = WM_USER + 1; //User-defined message

type
...
var
...
NotifyIconData   : TNotifyIconData;
implementation
procedure Tfrmmain.FormCreate(Sender: TObject);
begin
with notifyicondata do
begin
hicon := icon.Handle;
strpcopy(sztip, application.Title);
wnd := handle;
ucallbackmessage  := wm_icontray;
uid :=1;
uflags  := nif_message + nif_icon + nif_tip;
cbsize  := sizeof(tnotifyicondata);
end;
shell_notifyicon(nim_add,@notifyicondata);
setwindowlong(application.Handle, gwl_exstyle,ws_ex_toolwindow);
end;
Syntax Highlighted with https://pascal-id.org/syntax

-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...


procedure tfrmmain.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;
Syntax Highlighted with https://pascal-id.org/syntax

-menampilkan dan menyembunyikan form
-tambahkan Exit dan Show pada item di popupmenu


procedure Tfrmmain.Show1Click(Sender: TObject);
begin
;
//shell_notifyicon(nim_delete,@notifyicondata);
end;
procedure Tfrmmain.Exit1Click(Sender: TObject);
begin
shell_notifyicon(nim_delete,@notifyicondata);
application.ProcessMessages;
application.Terminate;
end;
procedure Tfrmmain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action  := canone;
hide;
//shell_notifyicon(nim_add,@notifyicondata);
end;
Syntax Highlighted with https://pascal-id.org/syntax

Coinfest

Pascal Indonesia is Coinfest Asia 2024's official community partner! 🀝
β˜€οΈ Take part in Asia’s immersive Web3 festival, where innovation meets adoption.
🎟 Get your tickets at www.coinfest.asia and use our special promo code : CA24PASCALINDO to get 10% off!

Why Coinfest Asia?
● Unconventionally Engaging
Our immersive setting and programming leave you with more memory markers than any other event
● Dive into Emerging Markets
Get connected in Southeast Asia; the fastest-growing Web3 region in the world
● Jump straight into Adoption
Foster collaborations directly in Indonesia where there are 437k new crypto users each month

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com