Solved

A question on Shell function

Posted on 1998-12-29
3
182 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

914 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

12 Experts available now in Live!

Get 1:1 Help Now