?
Solved

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

Posted on 2004-03-25
8
Medium Priority
?
1,521 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
Independent Software Vendors: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 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