Thanks a lot!!! It works Great! I never thought it would be possible, hehe
:-)
I finally did it like this:
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
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
* "DraguVaso" <pi**********@h otmail.com> scripsit: I tried it, but unfortunately it didn't work :-(
This is the code I used:
<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 Function _
IsIconic(ByVal hWnd As IntPtr) As Boolean
End Function
Public Sub pbenmin()
Dim clsProc As New clsProcesses
Dim p As Process
p = clsProc.Process Extra()
Dim IsNormal As Boolean
'Dim HWND As Integer
Dim hwnd As IntPtr
hwnd = p.Handle
'p#Handle' will return a /process/ handle, you need a /window/ handle.
Use 'p.MainWindowHa ndle' instead.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>