简体   繁体   English

如何在任务栏中显示我的表单

[英]How to show my form inside taskbar

I have created a winform application with visual studio c#, which has just two forms. 我已经用Visual Studio c#创建了一个Winform应用程序,它只有两种形式。

When the application is ran, the main form appears and if user presses the minimize button of it, the main form becomes hide and the other form appears. 运行该应用程序时,将显示主窗体,如果用户按下该窗体的最小化按钮,则主窗体将变为隐藏,而另一窗体将出现。

Every things goes fine but the problem is that the second form should open inside the taskbar (like what happens in jetaudio or KMPlayer and etc.). 一切正常,但问题是第二个表单应该在任务栏中打开(例如jetaudio或KMPlayer等中发生的事情)。

Edit : 编辑:

My second form is something like this : 我的第二种形式是这样的:

在此处输入图片说明

And i want to show it inside taskbar like below : 我想在任务栏中显示如下:

在此处输入图片说明

Each Form have option ShowInTaskbar =true/false 每个表单都有选项ShowInTaskbar = true / false

My code if you need 我的代码,如果你需要

 [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;
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM