Solved

A question on Shell function

Posted on 1998-12-29
3
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

752 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