Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)

[es] :: Pascal / Delphi / Kylix :: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)

[ Pregleda: 4868 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

gygy
Dragan Grbic

Član broj: 7861
Poruke: 205
*.flashnet.co.yu.



Profil

icon minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)09.12.2003. u 03:50 - pre 247 meseci
Kako da kad kliknem na minimize da mi icon-u ubaci pored sata, a da iz task bar-a ukloni aplikaciju tj. kao da program nije startovan, i kad kliknem na tu icon-icu da mi otvori program?
Pozdrav!!!
GYGY
GYGY
 
Odgovor na temu

Crazy Mix
Nemanja Avramovic
QuadraSoft
Mladenovac

Član broj: 7103
Poruke: 331
*.telekom.yu

ICQ: 266136396
Sajt: www.quadrasoft.co.sr


Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)09.12.2003. u 18:33 - pre 247 meseci
probaj ovu kmponentu... meni radi cool
http://www.torry.net/vcl/system/trayicons/trayicon.zip
zato se i zove cooltrayicon
 
Odgovor na temu

gygy
Dragan Grbic

Član broj: 7861
Poruke: 205
*.sezampro.yu



Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)09.12.2003. u 21:19 - pre 247 meseci
Hvala!
Komponenta je stvarno cool!
Ali komponentu moram svaki put da instalisem kad otvorim delphi.
Sta je u pitanju?
Pozdrav!!!
GYGY
GYGY
 
Odgovor na temu

Crazy Mix
Nemanja Avramovic
QuadraSoft
Mladenovac

Član broj: 7103
Poruke: 331
*.telekom.yu

ICQ: 266136396
Sajt: www.quadrasoft.co.sr


Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)10.12.2003. u 09:33 - pre 247 meseci
Ne moras. Mozda je neka nova verzija... Ne znam
Evo ja sam uploadovao stariju verziju koju sam malo izmenio (izbacio demo-e).
Otpakuj bilo gde, otvori CoolTrayIcon_D5.dpk (za delphi 5) ili CoolTrayIcon_D6.dpk (za delphi 6), kompajliraj, instaliraj, i to je to...
Prikačeni fajlovi
 
Odgovor na temu

vujke
Ivan Vujić
Network administrator
Astra Telekom
Mladenovac

Član broj: 366
Poruke: 249
*.verat.net



+1 Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)10.12.2003. u 11:28 - pre 247 meseci
Jesi li ubacio komponentu u search path tvog projekta?

 
Odgovor na temu

myrmidon
B.Robert
Tungusia

Član broj: 10428
Poruke: 55
*.ptt.yu



Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)20.12.2003. u 14:43 - pre 247 meseci
System Tray Delphi application - quick and easy

Placing Delphi applications in the System Tray in easy steps. The perfect place form programs that are left running for long periods of time with no user interaction.



More of this Feature
• Part 2: Animate Tray Icon with customized PopUp




Join the Discussion
"Post your views, comments, questions and doubts to this article."
Discuss!




Related Resources
• Shell exposed by Delphi
• API and Delphi
• Top shell tricks
• Message handling





Take a look at your Task Bar. See the area where the time is located? Are there any other icons there? The place is called the Windows System Tray. Would you like to place your Delphi application's icon there? Would you like that icon to be animated - or reflect the state of your application?

This would be useful for programs that are left running for long periods of time with no user interaction (background tasks you typically keep running on your PC all day long).

What you can do is to make your Delphi applications look as they are minimizing to the Tray (indstead to the Task Bar - right to the Win Start button) by placing an icon in the tray and simultaneously making your form(s) invisible.

Let's tray it!
Fortunately, creating an application that runs in the system tray is pretty easy - only one (API) function, Shell_NotifyIcon, is needed to accomplish the task.

The function is defined in the ShellAPI unit and requires two parameters. The first is a flag indicating whether the icon is being added, modified, or removed, and the second is a pointer to a TNotifyIconData structure holding the information about the icon. That includes the handle of the icon to show, the text to show as tool tip when the mouse is over the icon, the handle of the window that will receive the messages of the icon and the message type the icon will send to this window.

First, in your main form's Private section put the line:
TrayIconData: TNotifyIconData;

type
TMainForm = class(TForm)
procedure FormCreate(Sender: TObject);
private
TrayIconData: TNotifyIconData;
{ Private declarations }
public
{ Public declarations }
end;






Then, in your main form's OnCreate method, initialize the TrayIconData data structure and call the Shell_NotifyIcon function:

with TrayIconData do
begin
cbSize := SizeOf(TrayIconData);
Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := WM_ICONTRAY;
hIcon := Application.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;

Shell_NotifyIcon(NIM_ADD, @TrayIconData);






The Wnd parameter of the TrayIconData structure points to the window that receives notification messages associated with an icon.
The hIcon points to the icon we want to ad to the Tray - in this case Applications main icon is used.
The szTip holds the Tooltip text to display for the icon - in our case the title of the application. The szTip can hold up to 64 characters.

The uFlags parameter is set to tell the icon to process application messages, use the application's icon and its tip. The uCallbackMessage points to the application defined message identifier. The system uses the specified identifier for notification messages that it sends to the window identified by Wnd whenever a mouse event occurs in the bounding rectangle of the icon. This parameter is set to WM_ICONTRAY constant defined in the interface section of the forms unit and equals: WM_USER + 1;

You add the icon to the Tray by calling the Shell_NotifyIcon API function. The first parameter "NIM_ADD" adds an icon to the Tray area. The other two possible values, NIM_DELETE and NIM_MODIFY are used to delete or modify an icon in the Tray - we'll see how later in this article. The second parameter we send to the Shell_NotifyIcon is the initialized TrayIconData structure.

Take one...
If you RUN your project now you'll see an icon near the Clock in the Tray. Note three things.
1) First, nothing happens when you click (or do anything else with the mouse) on the icon placed in the Tray - we haven't created a procedure (message handler), yet.
2) Second, there is a button on the Task Bar (we obviously don't want it there).
3) Third, when you close your application, the icon remains in the Tray.

Take two...
Let's solve this backward. To have the icon removed from the Tray when you exit the application, you have to call the Shell_NotifyIcon again, but with the NIM_DELETE as the first parameter. You do this in the OnDestroy event handler for the Main form.

procedure TMainForm.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @TrayIconData);
end;






To hide the application (application's button) from the Task Bar we'll use a simple trick. In the Projects source code add the following line: Application.ShowMainForm := False; before the Application.CreateForm(TMainForm, MainForm); E.g let it look like:

...
begin
Application.Initialize;
Application.ShowMainForm := False;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.






And finally to have our Tray icon respond to mouse events we need to create a message handling procedure. First we declare a message handling procedure in the public part of the form declaration: procedure TrayMessage(var Msg: TMessage); message WM_ICONTRAY; Second the definition of this procedure looks like:

procedure TMainForm.TrayMessage(var Msg: TMessage);
begin
case Msg.lParam of
WM_LBUTTONDOWN:
begin
ShowMessage('Left button clicked
- let''s SHOW the Form!');
MainForm.Show;
end;
WM_RBUTTONDOWN:
begin
ShowMessage('Right button clicked
- let''s HIDE the Form!');
MainForm.Hide;
end;
end;
end;





This procedure is designed to handle only our message, the WM_ICONTRAY. It takes the LParam value from the message structure which can give us the state of the mouse upon the activation of the procedure. For the sake of simplicity we'll handle only left mouse down (WM_LBUTTONDOWN) and right mouse down (WM_RBUTTONDOWN). When the left mouse button is down on the icon we show the main form, when the right button is pressed we hide it. Of course there are other mouse input messages you can handle in the procedure, like, button up, button double click etc.



Myrmidon
 
Odgovor na temu

-zombie-
Tomica Jovanovic
freelance programmer
ni.ac.yu

Član broj: 4128
Poruke: 3448
*.dial.InfoSky.Net

Sajt: localhost


+5 Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)20.12.2003. u 16:29 - pre 247 meseci
kad već citiraš neki članak sa nekog sajta, ostavi i url da bi mogli da članak pogledamo u originalu, sa propisno formatiranim kodom, eventualno potražimo još sličnih...

http://delphi.about.com/library/weekly/aa121801a.htm

 
Odgovor na temu

myrmidon
B.Robert
Tungusia

Član broj: 10428
Poruke: 55
*.ptt.yu



Profil

icon Re: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)23.12.2003. u 15:57 - pre 247 meseci
Citat:
-zombie-:
kad već citiraš neki članak sa nekog sajta, ostavi i url da bi mogli da članak pogledamo u originalu, sa propisno formatiranim kodom, eventualno potražimo još sličnih...

http://delphi.about.com/library/weekly/aa121801a.htm


eto vidi da si nasao...
Myrmidon
 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: minimize to systray (ni temu da nazovem kako treba, ni da upotrebim pretragu. sramota...)

[ Pregleda: 4868 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.