How can I use Windows look'n'feel for the context menu in the system tray?

I work with NotifyIconand ContextMenuStrip, I do not want to use the default menu appearance that comes out of the box with this control, which is different from Windows (Vista in my case), using contextMenu.RenderMode = ToolStripRenderMode.ManagerRenderModeor contextMenu.RenderMode = ToolStripRenderMode.Professional:

alt text

I do not want this to use contextMenu.RenderMode = ToolStripRenderMode.System:

alt text

I just want to use the standard, regular Windows “look and feel”, as seen from countless, possibly non-application * grumble * applications:

alt textalt text

Any ideas guys on how to achieve this?

+5
source share
2 answers

Vista (.. , DropBox ) .

, . , , .

using System;
using System.Windows.Forms;
using System.Drawing;

public class AC : ApplicationContext
{
    NotifyIcon ni;
    public void menu_Quit(Object sender, EventArgs args)
    {
        ni.Dispose();
        ExitThread();
    }
    public AC()
    {
        ni = new NotifyIcon();
        ni.Icon = SystemIcons.Information;
        ContextMenu menu = new ContextMenu();
        menu.MenuItems.Add("Quit", new EventHandler(menu_Quit));
        ni.ContextMenu = menu;
        ni.Visible = true;
    }
    public static void Main(string[] args)
    {
        //Application.EnableVisualStyles();
        //Application.SetCompatibleTextRenderingDefault(false);
        AC ac = new AC();
        Application.Run(ac);        
    }
}
+4

, Windows:

1) Windows >

2) Tick ContextMenu > OK

3) Windows >

4) ContextMenu

5) ContextMenu1 > a > - ( myNotifyIconContext)

6) Form1.cs( ..) > Form1.Designer.cs

7) - :

// 
// notifyIcon1
// 
this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "My Notification Icon";
this.notifyIcon1.Visible = true;

ContextMenuStrip.

8) ( ):

this.notifyIcon1.ContextMenu = this.myNotifyIconContext;

et voila!

enter image description here

0

All Articles