Let's say if i appactivated a program and the title bar was something like "Guard" if i wanted to move that program into the center of the screen, or anywhere else. How would I go about doing that?
Printable View
Let's say if i appactivated a program and the title bar was something like "Guard" if i wanted to move that program into the center of the screen, or anywhere else. How would I go about doing that?
Use the SetWindowPos API
While SetWindowPos works, MoveWindow is easier.
I suggest that you use FindWindow to get the handle to the window and then MoveWindow to move it.
VB Code:
Dim lHwnd As Long lHwnd = FindWindow(vbNullString, "Guard") MoveWindow lHwnd, NewXPosition, NewYPosition, NewWidth, NewHeight, 1
Here are the declares:
VB Code:
Private Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long