Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

maximize program 1

Status
Not open for further replies.

k2w

Programmer
Dec 17, 2002
34
CA
Is there an API function that will maximize a program window if you have the process Id?

Thanks
 
The window isn't in the visual basic program itself. I'm talking about an outside application window, such as Word or another program, that I have already created a process for. I want to be able to maximize this particular process' window when needed.
 
You will need to use EnumWindows api to get all the top level windows, then test for the one you want, then use SetWindow api

There have been several recent posts in this forum - do a forum search on EnumWindows.
There is another example here:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Or use FindWindow(Ex), if you know its (unique) classname, parent window etc..

Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Private Const SW_MAXIMIZE = 3

Dim hWnd As Long
    
hWnd = FindWindow("Notepad", vbNullString)
If hWnd Then ShowWindow hWnd, SW_MAXIMIZE
Remedy
 
Thanks remedy.

Worked great, I just had to change hWnd to another variable name to avoid a compilation error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top