我如何使用Windows look'n'feel系统任务栏的上下文菜单? [英] How can I use the Windows look'n'feel for a system tray context menu?

查看:135
本文介绍了我如何使用Windows look'n'feel系统任务栏的上下文菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正与一个的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);		
	}
}

这篇关于我如何使用Windows look'n'feel系统任务栏的上下文菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆