从系统托盘打开Windows应用程序 [英] Open Windows Application from System Tray

查看:84
本文介绍了从系统托盘打开Windows应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个C#Windows应用程序,它用于按时显示一些消息(每小时)。

此应用程序在任务栏中隐藏,仅显示在系统托盘中。

当时间到达显示消息时,窗口应打开,并且应显示在所有打开的应用程序的顶部(例如chrome,adobe)读者等等。

我将如何实现这一点,Plz帮助。





谢谢

Magesh.M

Hi All,

I have a C# Windows Application, it is used to display some messages on time basis(Hourly).
This application is hidden from taskbar and only shown in system tray.
When the time reaches to display messages the window should open, and it should diplay in top of all opened Application(such as chrome, adobe reader , etc.).
How will i Achieve this , Plz Help.


Thanks
Magesh.M

推荐答案

您确定您的表单窗口状态和位置是否准确?



你可以试试下面的内容并让我知道它是怎么回事吗?



Have you made sure your form window state and position is accurate?

Can you try the below and let me know how it goes ?

Me.Location = New System.Drawing.Point(0, 0)
Me.WindowState = Windows.Forms.FormWindowState.Maximized
Me.TopMost = True
Me.ShowDialog()




this.Location = new System.Drawing.Point(0, 0);
this.WindowState = Windows.Forms.FormWindowState.Maximized;
this.TopMost = true;
this.ShowDialog();





此外,



试试看这个:

创建系统托盘应用程序在VB.NET中 [ ^ ]


大家好,



最后,我找到了解决方案对此,



i使用以下课程将我的应用程序带到所有其他已打开的应用程序前面..



Hi all,

At last, however i find the solution to this,

i had used the following class to bring my application front of all other opened applicatios..

public class ProcessManager
   {
       [DllImport("user32.dll")]
       private static extern bool ShowWindow(IntPtr hWnd, uint windowStyle);

       [DllImport("user32.dll")]
       private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);

       public ProcessManager()
       {
           string processName = "your process name here, if your process is something.exe then give 'something' ..";
           SearchProcessAndModifyState(processName);
       }

       private void SearchProcessAndModifyState(string targetProcessName)
       {
           Process specifiedProcess = null;
           var pro = Process.GetProcessesByName(targetProcessName);
           if (pro.Length > 0)
           {
               specifiedProcess = pro[0];
           }

           if (specifiedProcess != null)
           {
               ProcessManager.ShowWindow(specifiedProcess.MainWindowHandle, 1u);
               ProcessManager.SetWindowPos(specifiedProcess.MainWindowHandle, new IntPtr(-1), 0, 0, 0, 0, 3u);
           }
       }
   }







然后我需要的时候打开表单和




Then whenever i needs to open the form along with

Form.Show()



i只是实例化ProcessManager类,如


i just instantiate the ProcessManager class like

proc = new ProcessManager();







谢谢和问候

Magesh.M




Thanks and Regards
Magesh.M


这篇关于从系统托盘打开Windows应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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