DraguVaso
Fri Jul 16 07:16:28 CDT 2004
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.InteropServices.DllImport("user32.dll", _
EntryPoint:="SetForegroundWindow", _
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
Public Shared Function SetForegroundWindow(ByVal handle As IntPtr) As
Boolean
' Leave function empty
End Function
<System.Runtime.InteropServices.DllImport("user32.dll", _
EntryPoint:="ShowWindow", _
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
Private Shared Function ShowWindow(ByVal handle As IntPtr, ByVal nCmd As
Int32) As Boolean
' Leave function empty
End Function
<System.Runtime.InteropServices.DllImport("user32.dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
Private Shared Function IsIconic(ByVal hWnd As IntPtr) As Boolean
' Leave function empty
End Function
<System.Runtime.InteropServices.DllImport("user32.dll", _
EntryPoint:="IsIconic", _
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall, _
CharSet:=Runtime.InteropServices.CharSet.Unicode, SetLastError:=True)> _
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.MainWindowHandle
If IntPtr.Zero.Equals(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)
SetForegroundWindow(hwnd)
Else
'maximzed or restored
SetForegroundWindow(hwnd)
End If
End Sub
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:%23SPRXWyaEHA.1732@TK2MSFTNGP09.phx.gbl...
> * "DraguVaso" <pietercoucke@hotmail.com> scripsit:
> > I tried it, but unfortunately it didn't work :-(
> > This is the code I used:
> >
> > <System.Runtime.InteropServices.DllImport("user32.dll", _
> > EntryPoint:="IsIconic", _
> >
CallingConvention:=Runtime.InteropServices.CallingConvention.StdCall, _
> > CharSet:=Runtime.InteropServices.CharSet.Unicode,
SetLastError:=True)> _
> > 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.ProcessExtra()
> > 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.MainWindowHandle' instead.
>
> --
> Herfried K. Wagner [MVP]
> <URL:
http://dotnet.mvps.org/>