我使用visual studio c#创建了一个winform应用程序,它只有两种形式。
当应用程序运行时,将显示主窗体,如果用户按下它的最小化按钮,主窗体将变为隐藏,并显示另一个窗体。
每件事都很顺利,但问题是第二种形式应该在任务栏内打开(就像jetaudio或KMPlayer等中发生的那样)。
修改:
我的第二种形式是这样的:
我希望在下面的任务栏中显示它:
答案 0 :(得分:0)
每个表单都有选项ShowInTaskbar = true / false
如果您需要我的代码
[STAThread]
public static void Main()
{
SysTrayApp();
Application.Run();
}
private static NotifyIcon trayIcon;
private static ContextMenu trayMenu;
private static ContextMenu trayMenu2;
public static void SysTrayApp()
{
// Create a simple tray menu with only one item.
trayMenu2 = new ContextMenu();
trayMenu2.MenuItems.Add("Run test2", RunTest);
trayMenu = new ContextMenu();
trayMenu.MenuItems.Add("Run test", RunTest);
trayMenu.MenuItems.Add("Save-30", SaveData30).MergeMenu(trayMenu2);
trayMenu.MenuItems.Add("Save-80", SaveData80);
trayMenu.MenuItems.Add("Hide Log", HideLog);
trayMenu.MenuItems.Add("Show Log", ShowLog);
trayMenu.MenuItems.Add("Settings", OpenSettings);
trayMenu.MenuItems.Add("Exit", OnExit);
// Create a tray icon. In this example we use a
// standard system icon for simplicity, but you
// can of course use your own custom icon too.
trayIcon = new NotifyIcon();
trayIcon.Text = "MyTrayApp";
trayIcon.Icon = new Icon(@"C:\Users\vladimir\Downloads\Artdesigner-Emoticons-Cool.ico", 60, 60);
// Add menu to tray icon and show it.
trayIcon.ContextMenu = trayMenu;
trayIcon.Visible = true;
}