Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

Dev O'Connor 18-Jun-15 6:44am    
Please provide your code you are using to try and open the window.
Magesh M N 18-Jun-15 6:52am    
i just using show();
and for hide , just hide();
Dev O'Connor 18-Jun-15 12:21pm    
Please mark the answer as the solution if this has resolved your problem.

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

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


Try looking into this too:
Create a System Tray Application in VB.NET[^]
Share this answer
Magesh M N 18-Jun-15 7:08am    
I tried this, the form opens but it doesn't displays top of all other application....
Dev O'Connor 18-Jun-15 7:10am    
Try this:

Dim frm as Form = New MyFormName
Magesh M N 18-Jun-15 7:11am    
i am creating application with C# not with VB...
Dev O'Connor 18-Jun-15 7:12am    
Form frm = new MyFormName();
Magesh M N 18-Jun-15 7:14am    
Again , the form Opens but not on top of all other opened applications..
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
       private static extern bool ShowWindow(IntPtr hWnd, uint windowStyle);

       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' ..";

       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

i just instantiate the ProcessManager class like
proc = new ProcessManager();

Thanks and Regards
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900