Solved

A question on Shell function

Posted on 1998-12-29
3
181 Views
Last Modified: 2010-05-03
hi,
I make .exe for an application and use Shell to activate it
in a menu option. The application is activated but is minimised. I check the windowstate of the form and it's Normal.

Please advise how i can activate the application and make it
normal instead of minimised?

Thanks.
Andrea
0
Comment
Question by:tanmh
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
hddp666 earned 10 total points
ID: 1453136
When you call the program using the shell function, make sure that you include the windowstyle argument. It's optional, but the default is the window minimized. Here is the syntax:

Dim r as long ' value returned by program
r = Shell(pathname[,windowstyle])
r = Shell(C:\program.exe, 1)

pathname = "c:\windows\notepad.exe c:\My Documents\resume.txt"

This will open resume.txt using notepad.exe

pathname = "c:\applications\MyProgram.exe"

This will run MyProgram.exe


windowstyle value      window state upon execution

0      Window is hidden and focus is passed to the hidden window.
1      Window has focus and is restored to its original size and position.
2      Window is displayed minimized (taskbar icon) with focus.
3      Window is maximized with focus.
4      Window is restored to its most recent size and position. The currently active window remains active.
6      Window is displayed as an icon. Current window remains active.

vbHide                      0      
vbNormalFocus              1      
vbMinimizedFocus      2      
vbMaximizedFocus      3      
vbNormalNoFocus              4      
<NONE>                 <5>
vbMinimizedNoFocus      6


0
 

Author Comment

by:tanmh
ID: 1453137
hi,
thanks for the answer. it works!!!
just for clarification, why can't i set the window state in the form properties?

andrea
0
 
LVL 1

Expert Comment

by:hddp666
ID: 1453138
It's anybody's guess why the shell function ignores the windowstate property that is set at design-time. Maybe VB6.0 will have this bug fixed.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now