Code:'specify the screen position of a window Private Type POINTAPI X As Long Y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type WINDOWPLACEMENT Length As Long flags As Long showCmd As Long ptMinPosition As POINTAPI ptMaxPosition As POINTAPI rcNormalPosition As RECT End Type Private Declare Function SetWindowPlacement _ Lib "user32" (ByVal hwnd As Long, _ lpwndpl As WINDOWPLACEMENT) As Long Private Declare Function GetWindowPlacement _ Lib "user32" (ByVal hwnd As Long, lpwndpl As _ WINDOWPLACEMENT) As Long Private Declare Function FindWindow Lib _ "user32" Alias "FindWindowA" (ByVal lpClassName _ As String, ByVal lpWindowName As String) As Long Private Declare Function SetRect Lib "user32" _ (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, _ ByVal X2 As Long, ByVal Y2 As Long) As Long '========================================== Private Sub Command1_Click() Dim WndPlace As WINDOWPLACEMENT Dim h As Long Dim RetVal RetVal = Shell("C:\WINDOWS\notepad.exe C:\A VB Tips\alpha only.txt", 1) 'Shell "Notepad", vbHide h = FindWindow("Notepad", vbNullString) If h <> 0 Then WndPlace.Length = Len(WndPlace) Call GetWindowPlacement(h, WndPlace) Call SetRect(WndPlace.rcNormalPosition, 0, 3700, WndPlace.rcNormalPosition.Right, 4000) Call SetWindowPlacement(h, WndPlace) End If End Sub




Reply With Quote