0

I'm working on a project in which total 5 modules are there like HR, Accounts etc. The software is desingned in such a way that all these 5 modules are created seperately and connected to the main project using shell command. Now, the real problem is, if i first work in HR module and the after closing that i want to work in Accounts; the program control is nt transfering back to the main project from where i called the first shell command. is there any way to get this done. Please help me.

Thanks in advance

  • Without dirty Win32 hacks? Is COM interop an option (.net's `Process` class would be helpful I think)? – Mathieu Guindon Jun 11 '13 at 12:28
  • While that question explains how to "shell and wait" it won't actually help the focus ending up at another application as the have seperate input queues. – Deanna Mar 10 '14 at 11:30

2 Answers2

3

There is no "shell command" though VB6 does have a Shell function that can be used to run another program asynchronously.

If this is what you are using, and you have a simple case of program P0 that can spawn programs P1 through P5 and terminate. Each of these additional programs could re-run P0 as part of terminating. In this case you might want P0 to persist some state or that might not be necessary at all. If the required amount of state is minimal P0 through P5 could pass info back and forth as command line strings when they call Shell.

You could perhaps get "whizzier" and have P0 use a shell-and-wait technique and while waiting it could hide itself. Then once the P1, P2, etc. terminates P0 could make itself visible again.

There is also the option of creating P0 as a standard EXE and P1 through P5 as ActiveX EXEs invoked by P0.

There are also several kinds of IPC you might use instead to "federate" these separate programs (not "modules") into a cohesive application.

Bob77
  • 13,167
  • 1
  • 29
  • 37
1

Is there any reason why there have to be five executables? Some sort of multi-processing? Otherwise, I would simply put each module into a separate DLLs or OCXs. There would be a "master" program which would be there simply to load these components. You could either have the following classes in your DLL:

  • P1.Connect
  • P2.Connect
  • P3.Connect
  • P4.Connect
  • P5.Connect

Each one implementing an interface with a Load() method. This method loads the main form of the module.

Alternatively, you can be generic and have forms in the master program which load ActiveX controls from each OCX which contain the module GUI.

You would implement an event or callback from each Connect class so that when the module is closed, the master EXE knows about it.

If you absolutely must have separate EXEs, you could do this by implementing them as ActiveX EXEs, with the same class names as above. As I suggested, your "master EXE" would be responsible for loading each subsiduary module.

As an aside, regardless of which method you use, if you require five separate "start" icons, then you can create five shortcuts which refer to the master EXE, but with different command line parameters. Depending on which command line parameter used, you start a different module.

Mark Bertenshaw
  • 5,594
  • 2
  • 27
  • 40