Link to home
Start Free TrialLog in
Avatar of gotiya
gotiya

asked on

An extreme ......Shell window problem in VB6

In my VB6 application I make a Shell call to another "exe" application which executes or pops-up an MS-DOS window and then displays a graph window. Therefore there are two windows poped-up when the VB application executes the Shell command.

However, I wish that the MS-DOS window get minimised while the other window (one with a graph) remains open. I have tried using Shell("myapplication.exe",vbHide) and also Shell("myapplication", vbMinimizedNoFocus) with the result that, my graph window also gets hidden or minimised which is not what I want.

Any help is most wanted and welcomed...please...


Help me out...

Josh
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi gotiya,

The problem is perhaps out of your control! It depends on the application you are shelling out to. If it has control over its child windows and therefore minimises them when it is minimised itself then it could be tricky to work around.

However you could use a combination of API calls such as FindWindow to get a handle to the DOS window

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MINIMIZE = 6

Private Sub Launch_Click()
 Shell "......."
 Dim hWndDOS As Long
 hWndDOS = FindWindow(vbNullString,"The name of the DOS window (Its Exact title)")
 ShowWindow( hWndDOS,SW_MINIMIZE)
End Sub

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
Avatar of gotiya
gotiya

ASKER

Hi Tim,

Thank u for ur responce. However, I tried using the API call but it does not seem to work. I think the application does has a control over the child window. Let me ask you if there is an API call to HideWindow just like the one you showed earlier ShowWindow ?
ASKER CERTIFIED SOLUTION
Avatar of VBtorment
VBtorment

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gotiya

ASKER

thank you VNtorment
It does work.
Just split the points evenly I guess, the ShowWindow works, just with hide not minimize as supplied by VBtorment.
Or not as the case may be!