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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximized an application window

Status
Not open for further replies.

Bitaoo

Programmer
Dec 18, 2002
81
US


Hello,

I have a problem and hope you can help me. There is a VB6 application (test1.exe) that is running on system.
In another VB6 application (test2.exe) first I check if test1.exe is running or not and then if it is running I'll
activate it by AppActivate. The problem is that if the application window of test1.exe is minimized it is not
activated by AppActivate, How can I maximized the application window before activating it? Or any other
solution...

Thanks a lot,
--Bita
 
Suppose the caption of the window of application test1.exe is My App 1. Then following code will do the trick.
___
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
Const SW_MAXIMIZE = 3
'---
Dim strCaption As String, hW As Long
strCaption = "My App 1" 'Same title that you pass to AppActivate().
hW = FindWindow(vbNullString, strCaption)
If hW <> 0 Then ShowWindow hW, SW_MAXIMIZE
___
ShowWindow also sets the focus to the maximized window. You don't even need to call AppActivate.
 
Hypetia, thanks a lot for your response. It is good
if I know the window name but when I don't know that
what can I do. I just know that the name of exe file.

Thanks,
--Bita
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top