?
Solved

With Parameters, How to shell calc.exe and bring it into focus when minimized?

Posted on 2004-03-25
8
Medium Priority
?
1,514 Views
Last Modified: 2012-06-21
Experts

I have an executable (child.exe) that needs to be launched from a visual basic (Parent.exe)

the child.exe can be called with Command Line Parameters

three different ways to launch the application

Using a previously answered question
( How to shell calc.exe and bring it into focus when minimized?)

i'm able to launch the application and activate it if its minimized

But how can I pass parameters to the Child.exe from the Parent.exe if the Executable is already running

All help is greatly appreciated




0
Comment
Question by:MichealMcLoughlin
[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
8 Comments
 
LVL 5

Expert Comment

by:g0rath
ID: 10677927
and you tried

Shell Path2Cal & "Calc.exe", vbNormalFocus

of course you could also use

ShellExecute

check out this example

http://vbnet.mvps.org/index.html?code/shell/shellexecute.htm
0
 
LVL 4

Expert Comment

by:xassets
ID: 10677984
I don't think you can pass a new command line to an existing process, but there are alternatives

1. Check App.PrevInstance and if it returns true, use FindWindow etc to get its hWnd and then use SendMessage or PostMessage to send a WM_CLOSE message to terminate the previous instance. Then your instance can carry on

2. Make the application an ActiveX EXE. Then your second instance can invoke a Class Method on the first instance and pass the command line paramters to it.

3. Implement a message handler, and use a WM_USER message to communicate from the second instance to the first instance. The message can carry a pointer to the command line provided its in global shared memory.

4. Same as 3. but use a file to pass the parameters instead of global shared memory.

0
 
LVL 5

Expert Comment

by:g0rath
ID: 10677999
of course maybe you've allready done this and the program just isn't in focus

then you could use


Private Declare Function SetFocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


Dim windowHwnd as Long

windowHwnd = FindWindow(vbNullString,"Calculator")
Call SetFocus(windowHwnd)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:WilfredoPerez
ID: 10678017
You can create new project and make 2 classes parent child and combine both projects into one
0
 
LVL 28

Expert Comment

by:Ark
ID: 10682504
Sorry if I misunderstand your question, but probably you're looking for smth like this:
http://www.freevbcode.com/ShowCode.Asp?ID=2201
>>When you associate your application with data files, often you don't need to open a new a instance of application when a file is doubleclicked. Instead, you just want to send a command string (file name) to the previous instance. This application demonstrates a technique that allows you to do this without subclassing, using an invisible command button. The same technique can be useful for sending messages between two applications.<<
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11424409
PAQed - no points refunded (of 100)

modulo
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

741 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