petershaw9
asked on
Show a icon on the windows task bar
In my program, I use a timer, it executes procedure every 10 sec, and show me a message(MesssageDlg). I like it shows me a icon on the windows task bar, and if I click on the task bar, it can response my click (means the click can trigger a procedure). How can I do this?
Thank you very much.
Peter Shaw
Thank you very much.
Peter Shaw
The reply from Peter Larsen is quite correct, however if you get hold of a copy of the RX component suite (www.rxlib.com) there are a couple of components that will create a systray app, also I think that there are some similar components on the Delphi5 companion disk.
Cheers - Walter McKie
Cheers - Walter McKie
The point is: Do you mean the Taskbar or the System Tray?
The taskbar is the entire bar at the bottom of your screen, where the windows you have on your screen are displayed, and the system tray is the rectangle at the lower right corner of your screen where the programs that reside in memory (usually) show up.
If you want to use the systemtray, you can download a component here:
http://www.silicmdr.com/Freeware.htm
It's relatively easy to use and it can respond to clicks.
If you want a window on the taskbar, you could for example create a messagebox with no owner:
MessageBox(0,'Hello world!','MBox',MB_OK Or MB_ICONWARNING);
The taskbar is the entire bar at the bottom of your screen, where the windows you have on your screen are displayed, and the system tray is the rectangle at the lower right corner of your screen where the programs that reside in memory (usually) show up.
If you want to use the systemtray, you can download a component here:
http://www.silicmdr.com/Freeware.htm
It's relatively easy to use and it can respond to clicks.
If you want a window on the taskbar, you could for example create a messagebox with no owner:
MessageBox(0,'Hello world!','MBox',MB_OK Or MB_ICONWARNING);
ASKER
Thank all of you very much.
I haven't try the components. But I try the MessageBox(0,'Hello world!','MBox',MB_OK Or MB_ICONWARNING);
It shows a icon on the taskbar, but it shows box on the screen too, that is I don't want.
Nrico said a program can show on the system tray. Can I just show a form or anything that generated by my program shows on the system tray? and if I click on it, It can response to me, so that I can write code. For example if I click on it, a form shows up.
Peter Shaw
I haven't try the components. But I try the MessageBox(0,'Hello world!','MBox',MB_OK Or MB_ICONWARNING);
It shows a icon on the taskbar, but it shows box on the screen too, that is I don't want.
Nrico said a program can show on the system tray. Can I just show a form or anything that generated by my program shows on the system tray? and if I click on it, It can response to me, so that I can write code. For example if I click on it, a form shows up.
Peter Shaw
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have done the icon on the systray. but I found the popupmenu short cut is not working. I used the applicationevents component's the shortcut event and also add a couple of lines on the WinProc procedure, like if Msg.msg = WM_kEYdOWN then if msg.wparam = ord('o') then open1click(self);
these didn't work. How can I let the popup menu shortcut work?
Thanks
Peter Shaw
these didn't work. How can I let the popup menu shortcut work?
Thanks
Peter Shaw
I will look into it very soon..
TPopUpMenu dont have its own WindowHandle, so it's not possible to set focus to the menu.
The menu is inherited from TMenu/Tcomponent, and TComponent dont have a WindowHandle, because it's not a visible control. It do have a handle, but it comes from TApplication.Handle.
So it is not possible to set focus to the menu only, but to its owner.
I will try to find a solution to this problem - and if i find one, i will post a comment here.
Regards
Peter
The menu is inherited from TMenu/Tcomponent, and TComponent dont have a WindowHandle, because it's not a visible control. It do have a handle, but it comes from TApplication.Handle.
So it is not possible to set focus to the menu only, but to its owner.
I will try to find a solution to this problem - and if i find one, i will post a comment here.
Regards
Peter
ASKER
Thank u very much.
Peter Shaw
Peter Shaw
ASKER
peter
I realise I didn't the explain my question clearly. Maybe it mislead you. So I would like to clarify the question. The problem is the Accelerator keys in the popmenu do not work.
Best regards
Peter Shaw
I realise I didn't the explain my question clearly. Maybe it mislead you. So I would like to clarify the question. The problem is the Accelerator keys in the popmenu do not work.
Best regards
Peter Shaw
Accelerator keys - is that the same as short-cuts ??
ASKER
Similar. In the manu or popmanu caption,
we write Open as &Open, so that there is an underscore under the 'O'. That is formally called Accelerator key.
petershaw
we write Open as &Open, so that there is an underscore under the 'O'. That is formally called Accelerator key.
petershaw
OK,
But it doesn't matter - the problem is still the same.
The menu must have focus before it can receive key events.
Take a look at the following sample :
(The popupmenu is own by form1).
Form1.Show;
PopUpMenu1.PopUp(XPos, YPos);
Form1.SetFocus;
This is what it takes - now the menu is capable of receiving key events, because the owner of the windowhandle is visible.
If this is very important to you, i think you should consider to use a form (TForm) as a popupmenu.
Regards
Peter
But it doesn't matter - the problem is still the same.
The menu must have focus before it can receive key events.
Take a look at the following sample :
(The popupmenu is own by form1).
Form1.Show;
PopUpMenu1.PopUp(XPos, YPos);
Form1.SetFocus;
This is what it takes - now the menu is capable of receiving key events, because the owner of the windowhandle is visible.
If this is very important to you, i think you should consider to use a form (TForm) as a popupmenu.
Regards
Peter
ASKER
peter
Thank u very much. I will try this.
Peter Shaw
Thank u very much. I will try this.
Peter Shaw
Hi Peter,
You could place a TPopUpMenu on a TForm. Size the form downto e.g. 20x20 pixels and only make it visible when the menu is needed - also remember to hide the border :
PopUpMenu1.PopUp(XPos, YPos);
PopForm.Left:=XPos+10;
PopForm.Top:=YPos+10;
PopForm.Show;
PopForm.SetFocus; //if it is needed.
I think you should rewrite the question into a new question - just to make sure that i have got this WindowHandle stuff right.
Maybe someone else have solved the problem.
Regards
Peter
You could place a TPopUpMenu on a TForm. Size the form downto e.g. 20x20 pixels and only make it visible when the menu is needed - also remember to hide the border :
PopUpMenu1.PopUp(XPos, YPos);
PopForm.Left:=XPos+10;
PopForm.Top:=YPos+10;
PopForm.Show;
PopForm.SetFocus; //if it is needed.
I think you should rewrite the question into a new question - just to make sure that i have got this WindowHandle stuff right.
Maybe someone else have solved the problem.
Regards
Peter
http://www.borland.com/devsupport/delphi/faq/FAQ2911D.html
Good luck
PL