VB Code:
Option Explicit
Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Private Declare Function GetWindowRect Lib "User32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Sub SetWindowPos Lib "User32" _
(ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, _
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim tWnd As Long
Dim frmname As String
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim sizeofwin As RECT
Dim Oleft As Long, oTop As Long, oRight As Long, oBottom As Long
Private Sub Command1_Click()
frmname = "Notepad"
tWnd = FindWindow(frmname, vbNullString) ' Change stuff in quotes so it will shrink it!! i.e. for paint it would be "paint"
MsgBox tWnd
GetWindowRect tWnd, sizeofwin 'oLeft = Sizeofwin.Left: oTop = Sizeofwin.Top: oRight = Sizeofwin.Right: oBottom = Sizeofwin.Bottom
Oleft = sizeofwin.Left: oTop = sizeofwin.Top: oRight = sizeofwin.Right: oBottom = sizeofwin.Bottom
If tWnd <> 0 Then
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_HIDEWINDOW
Else
MsgBox frmname & " not found!"
End If
End Sub
Private Sub Command2_Click()
SetWindowPos tWnd, -1, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
SetWindowPos tWnd, -2, Oleft, oTop, oRight - Oleft, oBottom - oTop, SWP_SHOWWINDOW
DoEvents
End Sub