Current time: 06-25-2018, 09:03 PM Stay in touch via Twitter Facebook RSS Feed
Ada Baiknya anda baca Peraturan Forum ForNesia Disini Dan Disitu Sebelum Terlambat!
System Registration Forums Mulai Kedepan Sewaktu waktu akan Di Tutup.
Silahkan Dibaca Mengenai Auto Pruning User . Agar tidak ada pertanyaan lagi tentang kehilangan akses forum.



[Share] cara buat tray icon delphi

03-26-2014 03:44 PM cara buat tray icon delphi
#1


ahminblack Away
HunteR
HunteR
*

Posts: 37
Joined: Mar 2014

Reputation:

FCoin: 2.00ƒc

[Image: tray.jpg]


dibawah ini source code beserta tampilan script lengkapnya

script lengkap :

Pada Unit Exe :

program Tray_Icon;
//==========================================================//
//copyright : http://olvandra.blogspot.com //
// http://meanddelphi.blogspot.com //
//==========================================================//

uses
Forms,
Controls, Dialogs, ShellApi, Windows, // <<<<<<<<< uses yg diperlukan
UTrayIcon in 'UTrayIcon.pas' {TrayIcon};

{$R *.res}
var
NotifyIconData : TNotifyIconData;
begin
Application.Initialize;
Application.ShowMainForm := true; // fungsi untuk pada saat run Munculkan Form atau tidak nilai True berarti Muncul dan False berarti Hide
Application.Title := 'Open Aplikasi Tray Icon';
Application.CreateForm(TTrayIcon, TrayIcon);
NotifyIconData.cbSize := SizeOf( NotifyIconData );
NotifyIconData.Wnd := Trayicon.Handle;
NotifyIconData.uCallbackMessage := WM_ShellIcon;
NotifyIconData.hIcon := Application.Icon.Handle;
NotifyIconData.szTip := 'Open Aplikasi Tray Icon';
NotifyIconData.uFlags := NIF_TIP + NIF_MESSAGE + NIF_ICON;
try
Shell_NotifyIcon( NIM_ADD, @NotifyIconData );
ShowWindow(Application.Handle, SW_HIDE);
Application.Run;
finally
Shell_NotifyIcon( NIM_DELETE, @NotifyIconData );
end;
end.
=====================end Code===================

Pada Form Unit:

unit UTrayIcon;
//==========================================================//
//copyright : http://olvandra.blogspot.com //
// http://meanddelphi.blogspot.com //
//==========================================================//

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ExtCtrls,Shellapi, ComCtrls, ImgList;

const
WM_ShellIcon = WM_USER + 1;

type
TTrayIcon = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
Restore1: TMenuItem;
Hide1: TMenuItem;
N2: TMenuItem;
Exit1: TMenuItem;
N3: TMenuItem;
httpolvandrablogspotcom1: TMenuItem;
Label1: TLabel;
Image1: TImage;
StatusBar1: TStatusBar;
ImageList1: TImageList;
procedure FormActivate(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure Restore1Click(Sender: TObject);
procedure Hide1Click(Sender: TObject);
procedure httpolvandrablogspotcom1Click(Sender: TObject);
private
{ Private declarations }
procedure O_nsShellIcon( var Msg : TMessage ); message WM_ShellIcon;
procedure O_nsMinimize( var Msg : TWMSysCommand ); message WM_SYSCOMMAND;
public
{ Public declarations }
end;

var
TrayIcon: TTrayIcon;

implementation

{$R *.dfm}

//script Button minimize = SC_MINIMIZE : //script tombol Close = SC_CLOSE
//jika Button Minimize di tekan
procedure TTrayIcon.O_nsMinimize(var Msg: TWMSysCommand);
begin
if( Msg.CmdType = SC_MINIMIZE ) then // ScMINIMIZE bisa di ganti dengan SC_CLOSE
Hide
else
inherited;
end;

//script create Tray icon dan Popupmenu
procedure TTrayIcon.O_nsShellIcon(var Msg: TMessage);
var
O_ns : TPoint;
begin
case Msg.LParam of
WM_LBUTTONDBLCLK : begin
Show;
SetForegroundWindow( Handle );
end;
WM_RBUTTONUP : begin
SetForegroundWindow( Handle );
GetCursorPos( O_ns );
PopupMenu1.Popup( O_ns.x, O_ns.y );
PostMessage( Handle, WM_USER, 0, 0 );
end;
end;
end;

//script untuk hidden Form di TASKBAR saat run(Sw_showmodal atau Sw_Hide)
procedure TTrayIcon.FormActivate(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE); // Sw-Hide bisa diganti dengan Sw_Showmodal ;
end;

//script untuk menghentikan program
procedure TTrayIcon.Exit1Click(Sender: TObject);
begin
Application.Terminate;
end;

//script untuk memunculkan Form pada Popupmenu
procedure TTrayIcon.Restore1Click(Sender: TObject);
begin
Show;
SetForegroundWindow( Handle );
end;

//script untuk sembuntikan Form pada popupmenu
procedure TTrayIcon.Hide1Click(Sender: TObject);
begin
Hide;
end;

//script untuk memanggil link (tambahkan shellapi pada uses paling atas)
procedure TTrayIcon.httpolvandrablogspotcom1Click(Sender: TObject);
begin
ShellExecute(Application.handle, 'open', 'http://olvandra.blogspot.com', nil, nil,
SW_ShowNormal);
end;
end.

klow belum ngerti om ini source code dbawah
Register or Login to see this content

ahminblack, proud to be a member of ForNesia Family since Mar 2014.
(This post was last modified: 12-25-2014 10:29 AM by smoz.)
12-22-2014 06:10 AM RE: cara buat tray icon delphi
#2


qibIP Away
FNS MEMBER
FNS Member
**

Posts: 136
Joined: Jun 2014

Reputation:

FCoin: 2.09ƒc
Thread Copas ya mbah ? Google itu haha

qibIP, Copyright©2014, All Right Reserved

[Image: Untitled20141208144910.jpg]
12-28-2014 04:01 PM RE: cara buat tray icon delphi
#3


risvhal Away
HunteR
HunteR
*

Posts: 50
Joined: Feb 2014

Reputation:

FCoin: 2.00ƒc
harusnya komponen juga di share, gak jalan kalo komponen gak ada..
12-28-2014 04:47 PM RE: cara buat tray icon delphi
#4


bayputra Away
HunteR
HunteR
*

Posts: 63
Joined: Dec 2014

Reputation:

FCoin: 3.50ƒc
cara ganti icon nya itu gimana ya?
yang ijo kuning merah itu?
12-30-2014 01:31 AM RE: cara buat tray icon delphi
#5


smoz Away
Coding Moderators
Coding Moderators
*****

Posts: 78
Joined: Feb 2014

Reputation:

FCoin: 2.09ƒc
(12-28-2014 04:01 PM)risvhal Wrote:  harusnya komponen juga di share, gak jalan kalo komponen gak ada..

gak perlu komponen gan...cuma segitu codingnya

(12-28-2014 04:47 PM)bayputra Wrote:  cara ganti icon nya itu gimana ya?
yang ijo kuning merah itu?
itu setting pda popupmenu gan...
sprti ini gan
[Image: phphd182y.jpg]

[Image: fornesia_2.gif]
12-30-2014 11:41 AM RE: cara buat tray icon delphi
#6


arief29 Away
FNS MEMBER
FNS Member
**

Posts: 179
Joined: Dec 2014

Reputation:

FCoin: 2.00ƒc
Itu pada unit exe masukkin nya gimana gan?

“Jangan tanyakan apa yang telah diberikan negara padamu, tapi tanyakan apa yang telah kamu berikan untuk negara”
01-05-2015 12:48 PM RE: cara buat tray icon delphi
#7


Chapunkz Away
HunteR
HunteR
*

Posts: 82
Joined: Dec 2014

Reputation:

FCoin: 2.95ƒc
kepanjangan codenya ini mbah, kn tujuan intinya adalah membuat TrayIcon, itupun make komponen buahaha
tinggal ambil intinya aja, biar gk trlalu bingung lihatnya sm penerapannya ketawaaa

Get Premium Android Apps For Free !!!
01-05-2015 02:26 PM RE: cara buat tray icon delphi
#8


xdothunter Away
HunteR
HunteR
*

Posts: 67
Joined: Oct 2014

Reputation:

FCoin: 2.24ƒc
sebenarnya pake komponen cooltray juga bisa malah lebih simpel ^_^




Possibly Related Threads...
Thread: Author Last Post
  [Share] Cara Install Componen Zeos Pada Delphi Auryn 04-05-2016 11:53 PM
Last Post: saling percaya
  [Share] cara membuat teks berjalan di form delphi jack 08-31-2014 06:22 PM
Last Post: justlab

Search thread:


[-]
Advertisement