我正在使用 NotifyIcon
和 ContextMenuStrip
,我不想使用默认菜单外观,它随此控件开箱即用这与使用 contextMenu.RenderMode = ToolStripRenderMode.ManagerRenderMode
或 contextMenu.RenderMode = ToolStripRenderMode.Professional
的 Windows(在我的例子中是 Vista)不同:
我不想使用 contextMenu.RenderMode = ToolStripRenderMode.System
:
我只想使用在无数可能非 .net 应用程序中看到的标准、普通 Windows“外观和感觉”*提示*:
关于如何实现这一目标的任何想法?
最佳答案
在 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);
}
}
关于c# - 如何将 Windows 外观用于系统托盘上下文菜单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/718386/