Solved

Minimize to TNA (2)

Posted on 1998-11-16
20
216 Views
Last Modified: 2010-04-03
Once, I have already asked this, but it didn't work, because I got Error "Shell_NotifyIcon (Proc) is unknown Identifer".
So, how to hide an Application, and minimize it to the SystemTray or TNA (where the Win32-Clock, ICQ-Flower etc) is
and show it when clicking on the Icon there.

A little Sub-Menu with 'EXIT'-Function would also be usefull.
thanx, Omsec
0
Comment
Question by:omsec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 3
  • +1
20 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1347024
omsec

Here is code to do just that... or if you leave your email address I will mail you a component that does the whole thing for you...

unit systryico;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Stdctrls, comctrls, Shellapi;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  procedure IconCallBackMessage( var Mess : TMessage ); message WM_USER
  + 100;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
   Icd : TNotifyIconData;
begin
     ShowWindow(Application.handle, SW_HIDE);
     Self.Hide;
     with Icd do
     begin
           cbSize := SizeOf( TNotifyIconData );
           Wnd := Form1.Handle;
           uID := 1;
           uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
           uCallbackMessage := WM_USER + 100;
           hIcon := Application.Icon.Handle;
           szTip := 'Cool I got it right Wooooo Weeeee';
     end;
     Shell_NotifyIcon( NIM_ADD, @Icd );
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
   Icd : TNotifyIconData;
begin
     with Icd do
     begin
           cbSize := SizeOf( TNotifyIconData );
           Wnd := Form1.Handle;
           uID := 1;
           uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
           uCallbackMessage := WM_USER + 100;
           hIcon := Application.Icon.Handle;
           szTip := 'Cool I got it right Wooooo Weeeee';
// All the above is probably not needed.
     end;
     Shell_NotifyIcon( NIM_DELETE, @Icd );
end;

procedure TForm1.IconCallBackMessage( var Mess : TMessage );
var
   sEventLog : String;
begin
     case Mess.lParam of
// Do whatever you wish here. For example popup up a menu on a right click.
          WM_LBUTTONDBLCLK  : sEventLog := 'Left Double Click';
          WM_LBUTTONDOWN    : sEventLog := 'Left Down';
          WM_LBUTTONUP      : sEventLog := 'Left Up';
          WM_MBUTTONDBLCLK  : sEventLog := 'M Dbl';
          WM_MBUTTONDOWN    : sEventLog := 'M D';
          WM_MBUTTONUP      : sEventLog := 'M U';
          WM_MOUSEMOVE      : sEventLog :=  'movement';
          WM_MOUSEWHEEL     : sEventLog := 'Wheel';
          WM_RBUTTONDBLCLK  : sEventLog := 'r dbl';
          WM_RBUTTONDOWN    : sEventLog := 'r down';
          WM_RBUTTONUP      : sEventLog := 'r up';
     end;
end;

end.

Later
BoRiS
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347025
hi there !

it works, but.. I think he means to use a popup menu just above the system tray icon.
How to do it ?

bryan

0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347026
and how to change the icon ? and to have an animated icon ?

bryan

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:BoRiS
ID: 1347027
omsec/bryan7

Like I siad leave your email address and I'll send you a component I wrote that allows a popup menu, animated icons, onDblclick etc.

Also I need to now what version of delphi you are on... the component is for D3 & 4.

Later
BoRiS
0
 
LVL 2

Author Comment

by:omsec
ID: 1347028
Hi,
I'm actually at work and don't have Delphi here, so I can't check it out. You may send it to me at Home to rbieri@centralnet.ch
I use Delphi 4 Standard
By saying Menu, i meant, I need a PopUp that is activated on RightMouse Click and says EXIT to quit the program.

thx ;)
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347029
this is: AerithFantasy@earthling.net         AERITHFANTASY@EARTHLING.NET ( just in case =)   )

I use Delphi 3 c/s. Hmm.. how can I add some items to popup menu that appears by clicking on the application 'button' on the task bar ?

I'll drop some points for this, you are helping us both.
thanx.

bryan =)

0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347030
omsec/bryan7

I have sent my component to you, TBRSTrayIcon, this will allow you to asign a popupmenu to the icon, just drop a popup menu on the form and assign it to the popup filed in the object inspector on the trayicon component...

You'll see what I mean, if a popupmenu is assigned then the will atomatically popup on the rightbutton click...

Later
BoRiS
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347031
Boris

Wuz up?

I see you've been working hard around here, eh??  ;-)

Cheers,
Viktor
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347032
Viktornet

Yo, Yip you got that right :-)

You been busy wih exams or what¿

Later
BoRiS
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347033
naw.... just exploring some new stuff :)

I'm also working out so I don't have time to program that much...after I come from my workout, I just go to sleep.. I'm usually tired out after it, so...maybe I'll see you around on saturday or something like that :)

btw- Like da up side down question mark ;-)

Keep the good work ya :)

Cheers,
Viktor
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347034
Viktor

Hmmm, working out, at gym or boxing or what ¿, I have gone back to kick boxing and tai chi myself...

I will see you around, and you keep up the good work 2...

Later
BoRiS
0
 
LVL 2

Author Comment

by:omsec
ID: 1347035
hmh, the program deosn't exactly do what i need. it should first be in the normal task list, where you can switch programs. if the user click on the _ - Button (minimize) it should remove itself from the taskbar and just leave an icon in the SystemTray. On Click, it should appear again in maximized size.
maybe, i should mention, that my programs displays a splash form at start up
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347036
omsec

Did you receive the component I sent you for the taskbar icon, what you can do is create an onminimize event and then Set the BRSTrayIcon.Enabled to true and BRSTrayIcon.Showapp := False; and BRSTrayIcon.showManForm := False;...or you could use Application.OnMinimize event to pass the above stuff...

Then to get it back just set the stuff above to true and false on the BRSTrayIcon's on click event...

If you want I will send you a little example of the use of BRSTrayIcon, with the above done in the example...

Later
BoRiS
0
 
LVL 2

Author Comment

by:omsec
ID: 1347037
yeah thanx, and how do i sintall it ?
COMPONENT|INSTALL.. ?
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347038
Yip components / install component... select .dcu format

Later
BoRiS
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347039
Hi Boris, yeah, that works.

what are these properies for and how to use them ?
-Animated
-IconIndex
-IconList
-Interval
-ShowDesign

can you add these events ?

              WM_LBUTTONDBLCLK  : sEventLog := 'Left Double Click';
              WM_LBUTTONDOWN    : sEventLog := 'Left Down';
              WM_LBUTTONUP      : sEventLog := 'Left Up';
              WM_MBUTTONDBLCLK  : sEventLog := 'M Dbl';
              WM_MBUTTONDOWN    : sEventLog := 'M D';
              WM_MBUTTONUP      : sEventLog := 'M U';
              WM_MOUSEMOVE      : sEventLog :=  'movement';
              WM_MOUSEWHEEL     : sEventLog := 'Wheel';
              WM_RBUTTONDBLCLK  : sEventLog := 'r dbl';
              WM_RBUTTONDOWN    : sEventLog := 'r down';
              WM_RBUTTONUP      : sEventLog := 'r up';

wm_mousewheel ?

how to detect RBUTTONDBLCLK on any componenet ?

how do I make the icon blink ?
and to have an animated icon ?
and how to have icons in the popup menu ?
how do you get the coords(x,y) so the popup menu pops up above the icon ?


well, maybe too many questions.. sorry.

bryan

0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347040
bryan7

All of these questions will be revealed when I release my components with source in a week or two...but here are a couple of answeres

For the right click event try something like this

 procedure WMRButtonDown(var M: TWMRButtonDown); message WM_RBUTTONDOWN; //under the public heading

 then call

procedure TForm1.WMRButtonDown(var M: TWMRButtonDown);
var
Pt: Tpoint;
begin
inherited;
GetCursorPos(Pt);
 if M.Result = htClient then
  PopupMenu1.Popup(pt.x, pt.y);
end;

To get the x, y cord...

TrackPopupMenu API call

To set image Items in your popupmenu use the API call

SetMenuItemBitmaps(Menu1.Handle, 1, MF_BTCOMMAND, Bitmap1, Btimap2);

for more info on the above API's just check the win32.hlp file

Later
BoRiS
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347041
omsec

Did the component do what you needed it to...if so please evaluate this answer...

bryan7

did the component work for you, I will be releasing the source soon just added WM_MOUSEWHEEL event and MOUSEENTER and MOUSELEAVE...so I'm updating it and getting it cleaned up...

Later
BoRiS
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347042
I've tried to use teh TrackPopUpMenu, but had no succes..
and how do I have an ANIMATEDicon in the systray ?

the rest of things worked perfectly..

MOUSEENTER and MOUSELEAVE are functions like OnMouseMove ?
it would be great if components had something like "OnMouseMoveOut" ..

bryan

0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347043
bryan7

If you assign an Imagelist to my tray component and add you images to it, then set th animated to true then when the tray icon is shown it will animate the images in the image list.

The OnMouseEnter and OnMouseLeave are like "OnMouseOut" when the mouse enters the control it for example changes the text and when the mouse is moved out the control the text is set back to normal...

I'll mail you an example if you wish...

Later
BoRiS
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question