我如何使用Windows look'n'feel系统任务栏的上下文菜单?上下文、如何使用、任务栏、菜单

2023-09-04 02:43:41 作者:唐僧洗头爱飘柔

我正与一个的NotifyIcon 的ContextMenuStrip ,我不想用默认的菜单外观并使用感受它随开箱与此对照,其是不同的Windows(Vista的在我的情况)的 contextMenu.RenderMode = ToolStri prenderMode.ManagerRenderMode contextMenu.RenderMode = ToolStri prenderMode.Professional

I'm working with a NotifyIcon and ContextMenuStrip, I don't want to use the default menu look and feel which is shipped out of the box with this control which is different to Windows (Vista in my case) by using contextMenu.RenderMode = ToolStripRenderMode.ManagerRenderMode or contextMenu.RenderMode = ToolStripRenderMode.Professional:

我不希望用这种 contextMenu.RenderMode = ToolStri prenderMode.System

我只想使用标准的,正常的Windows外观和感觉是在无数看过,大概non-.net应用*发牢骚*:

I just want to use the standard, normal Windows "look and feel" as seen in countless, probably non-.net applications *grumble*:

在如何实现这一目标的任何想法家伙?

Any ideas guys on how to achieve this?

推荐答案

在Vista中,它呈现正确的(即,以同样的方式DropBox的呈现在我的机器上)使用所有的默认设置时。

On Vista, it renders correctly (i.e., the same way DropBox renders on my machine) when using all the defaults.

下面是对我的作品的示例程序。试试吧,如果不正确地呈现给你,请在取消两个注释行。

Here's a sample program that works for me. Try it, and if it doesn't render correctly for you, try uncommenting the two commented lines.

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);		
	}
}
 
精彩推荐