Notify Icon Menu Strip

135 views
Skip to first unread message

adityo dwiarto

unread,
May 8, 2008, 6:44:32 AM5/8/08
to dotnetdevelopment
hi all,

I have created a NotifyIcon with my application, when I right-click on the SystemTrayIcon, a menu appears on upper right-hand-side of the screen.
though the menu strip shows, unfortunately I can only adjust it by (x, y) position to the screen, and not relative to the SystemTray postion
I want it to be shown as how a ContextMenu usually does, right above the SystemIconTray.

            notifyIconTray.MouseClick += delegate
            {
                //notifyIconMenuStrip.Show(1024, 768); //<-- this
                notifyIconMenuStrip.Show(1024, 768);
            };
it says:
  void ToolStripDropDown.Show(Control control, Point position)                                                                                                                                                                .
  control: The control (typically, a System.Windows.Forms.ToolStripDropDownButton) that is the reference point for the System.Windows.Forms.ToolStripDropDown position. .

Can anybody give me a tip?

Wek

unread,
May 10, 2008, 12:40:48 PM5/10/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Well, I think you can adjust the menu by the mouse position. You get
the mouse position (normally when the ContextMenu is called, the mouse
is over the SystemTray icon), and then you show the menu in this
position, like this (sorry, some parts are writen in VB, I don't know
C#)

First you've to add a EventHandler:
AddHandler NotifyIcon1.MouseClick, AddressOf ShowMenu

The EventHandler points at this function
void ShowMenu(System.Object sender,
System.Windows.Forms.MouseEventArgs e)
{
ContextMenu.Show(e.X(), e.Y())
}

On 8 mayo, 12:44, "adityo dwiarto" <adityodwia...@gmail.com> wrote:
> hi all,
>
> I have created a NotifyIcon with my application, when I right-click on the
> SystemTrayIcon, a menu appears on upper right-hand-side of the screen.
> though the menu strip shows, unfortunately I can only adjust it by
> *(x, y)*position to the screen, and not relative to the SystemTray
> postion
> I want it to be shown as how a ContextMenu usually does, right above the
> SystemIconTray.
>
> notifyIconTray.MouseClick += delegate
> {
> //notifyIconMenuStrip.Show(1024, 768); //<-- this
> notifyIconMenuStrip.Show(1024, 768);
> };
> it says:
> void ToolStripDropDown.Show(*Control control,* Point
> position)
> .
> * control:* The control (typically, a
> System.Windows.Forms.ToolStripDropDownButton) that is the reference point
> for the System.Windows.Forms.ToolStripDropDown position. .
>
> Ca n anybody give me a tip?

adityo dwiarto

unread,
May 11, 2008, 10:04:06 PM5/11/08
to DotNetDe...@googlegroups.com
Morning,

Thanks for the logic, Wek..
it didn't crossed my mind that we can refer to the Mouse Position instead

System.Windows.Forms.MouseEventArgs e)

     {
         ContextMenu.Show(e.X(), e.Y())

and all I did was fixated on using the NotifyIcon (TrayIcon) itself as a position reference
though I haven't test this to resolve my problem, I'd like to thank u in advance.

Adityo

adityo dwiarto

unread,
May 12, 2008, 6:04:20 AM5/12/08
to DotNetDe...@googlegroups.com
<< CLOSED >>
 
Thanks, problem resolved
 

//notifyIconTray.ContextMenuStrip = notifyIconMenuStrip;

Reply all
Reply to author
Forward
0 new messages