system tray help

  • Thread starter shivaranjani.s.adimulam
  • Start date
S

shivaranjani.s.adimulam

Hi,


I have a .NET application where I want to restore the previos
application if it is already running and in minimized state.


The code I added is working fine in the case if the previous
application is only minimized but if it is minimized in to the
system tray then the code fails.


The main window handle value is 0 in this case.Is there any
alternative way to restore the applications from systray.


Thanks in advance
 
K

Ken Tucker [MVP]

Hi,

Post some code

Ken
------------------------
Hi,


I have a .NET application where I want to restore the previos
application if it is already running and in minimized state.


The code I added is working fine in the case if the previous
application is only minimized but if it is minimized in to the
system tray then the code fails.


The main window handle value is 0 in this case.Is there any
alternative way to restore the applications from systray.


Thanks in advance
 
R

Robert S. Liles

This code will take a program minimized into the system tray and restore it
to the screen with the focus instead of opening a new window.

Bobbo
__________________________________________
Public Class Form1
Inherits System.Windows.Forms.Form

Declare Auto Function FindWindow Lib "user32.dll" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Declare Auto Function ShowWindow Lib "user32.dll" _
(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean

#Region " Windows Form Designer generated code "
#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Const SW_RESTORE As Integer = 9
Dim SearchText As String = Me.Text
If UBound(System.Diagnostics.Process.GetProcessesByName( _
System.Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
Me.Text = Me.Text & "X"
Dim Handle As IntPtr = FindWindow(Nothing, SearchText)
ShowWindow(Handle, SW_RESTORE)
End
End If
End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top