Credit to Herfried...
Public Const GW_HWNDPREV = 3
Private Const SW_SHOW = 5
Private Const SW_RESTORE = 9
<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Se tForegroundWind ow", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Public Shared Function SetForegroundWi ndow(ByVal handle As IntPtr) As
Boolean
' Leave function empty
End Function
<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Sh owWindow", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Shared Function ShowWindow(ByVa l handle As IntPtr, ByVal nCmd As
Int32) As Boolean
' Leave function empty
End Function
<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Shared Function IsIconic(ByVal hWnd As IntPtr) As Boolean
' Leave function empty
End Function
<System.Runtime .InteropService s.DllImport("us er32.dll", _
EntryPoint:="Is Iconic", _
CallingConventi on:=Runtime.Int eropServices.Ca llingConvention .StdCall, _
CharSet:=Runtim e.InteropServic es.CharSet.Unic ode, SetLastError:=T rue)> _
Private Shared Function IsZoomed(ByVal hWnd As IntPtr) As Boolean
' Leave function empty
End Function
Public Shared Sub SetToForGround( ByVal hwnd As IntPtr)
Dim strStatus As String
'Dim hwnd As IntPtr
'hwnd = p.MainWindowHan dle
If IntPtr.Zero.Equ als(hwnd) Then
strStatus = ""
Exit Sub
End If
If IsIconic(hwnd) Then
strStatus = "MIN"
End If
'If IsZoomed(hwnd) Then
' IsNormal = True
'End If
'If IsIconic(hwnd) And IsZoomed(hwnd) Then
' IsNormal = True
'End If
If strStatus = "MIN" Then
'mimized
ShowWindow(hwnd , SW_RESTORE)
SetForegroundWi ndow(hwnd)
Else
'maximzed or restored
SetForegroundWi ndow(hwnd)
End If
End Sub
"Glenn" <g.***@comcast. net> wrote in message
news:#Y******** ******@TK2MSFTN GP11.phx.gbl:
I can determine if another instance is running, but how do I get it's
minimized window to restore (in VBNET). Using the standard win32 functions
is not working.
Thanks