Board index » Visual Studio » How to make a child process application active
|
cjgav
|
|
cjgav
|
How to make a child process application active
Visual Studio197
In application A, I create a local COM server. And in COM server process, I create a new process application B. The result is that application B is not active application. I tried to set the parameter STARTINFO, but it did not work. When I attached to the COM server process for debugging, the application B become acitve application after creation. So I guess if some work is done for COM server process by attaching to it. Any clue is appreciated. - |
| Alex
Registered User |
Sat Oct 14 11:15:38 CDT 2006
Re:How to make a child process application active
"RobinZhou" wrote:
QuoteIn application A, I create a local COM server. And in COM Is application A foreground application? If yes, then you could try to call AllowSetForegroundWindow for process B from it. Then process B would bring itself to foreground. Read more about foreground and background windows here: "Window Features" msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowfeatures.asp">msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowfeatures.asp See "Foreground and Background Windows" section. HTH Alex - |
| RobinZhou
Registered User |
Mon Oct 16 07:21:01 CDT 2006
Re:How to make a child process application active"Alex Blekhman" wrote: Quote"RobinZhou" wrote: BTW, the application B is C# application. - |
| Alex
Registered User |
Mon Oct 16 08:56:31 CDT 2006
Re:How to make a child process application active
RobinZhou wrote:
Quote>>In application A, I create a local COM server. And in COM should call AllowSetForegroundWindow with process ID of B process. Then process B should call SetForegroundWindow. - |
| RobinZhou
Registered User |
Mon Oct 16 09:40:03 CDT 2006
Re:How to make a child process application active
"Alex Blekhman" wrote:
QuoteRobinZhou wrote: process and set the window of application B as foreground window? it is a hacking way, right? You know generally create a new process in one proces, and the new process application is active. So I want to find the reason and get a normal solution. - |
| Alex
Registered User |
Mon Oct 16 10:23:32 CDT 2006
Re:How to make a child process application active
RobinZhou wrote:
QuoteYou mean I should use Enumwindow to enumerate windows in the COM server with ID of B process. Then in B process (not COM server process) call .NET equivalent of SetForegroundWindow to bring main window of B process to foreground. Process A just gives up its right to be foreground in favor of process B. But process B still needs to do the work to bring itself to foreground. However, if process A wasn't foreground in first place, then it doesn't have the right to be foreground, therefore it can't transfer this right to other processes, as well. Read more about it in the MSDN article by the link I posted earlier. - |
| RobinZhou
Registered User |
Tue Oct 17 08:45:02 CDT 2006
Re:How to make a child process application active"Alex Blekhman" wrote: QuoteRobinZhou wrote: the local COM server process, application B is active. So I guess if it is because of the local COM server is not a foreground process? Can we do some work about it? - |
| Alex
Registered User |
Tue Oct 17 09:13:20 CDT 2006
Re:How to make a child process application active
RobinZhou wrote:
Quote> foreground process, since COM server usually doesn't have any GUI at all. Probably you could call AttachThreadInput from process A (after AllowSetForegroundWindow) to attach to main window's thread of process B and then try to call SetForegroundWindow. However, it looks like hack and I'm not sure it will work reliably. - |
| RobinZhou
Registered User |
Tue Oct 17 09:27:02 CDT 2006
Re:How to make a child process application active"Alex Blekhman" wrote: QuoteRobinZhou wrote: class but local MSDN does not have. msdn.microsoft.com/wn3/aspx/postui.aspx&guid=&sloc=en-us&dg=microsoft.public.vc.language&base=msdn.microsoft.com/newsgroups/default.aspx&bclr=ececec&fclr=000000&sxml=msdn.microsoft.com/newsgroups/site.xml&stgxml=msdn.microsoft.com/newsgroups/settings.xml&sdgloc=en-US&tt=2">msdn.microsoft.com/wn3/aspx/postui.aspx&guid=&sloc=en-us&dg=microsoft.public.vc.language&base=msdn.microsoft.com/newsgroups/default.aspx&bclr=ececec&fclr=000000&sxml=msdn.microsoft.com/newsgroups/site.xml&stgxml=msdn.microsoft.com/newsgroups/settings.xml&sdgloc=en-US&tt=2 - |
| RobinZhou
Registered User |
Tue Oct 17 09:31:02 CDT 2006
Re:How to make a child process application active"RobinZhou" wrote: Quote
- |
| Alex
Registered User |
Tue Oct 17 10:30:17 CDT 2006
Re:How to make a child process application active
RobinZhou wrote:
Quote>Hm.. I don't know how to make COM server to become all. It just changes amount of CPU cycles granted to the process. This constant is relatively new, that's why your local MSDN doesn't mention it. - |
| RobinZhou
Registered User |
Wed Oct 18 08:36:01 CDT 2006
Re:How to make a child process application active"Alex Blekhman" wrote: QuoteRobinZhou wrote: |
| Alex
Registered User |
Wed Oct 18 11:10:59 CDT 2006
Re:How to make a child process application active
I think you should pass ID of process B (and may be main
window's handle, too) to process A. Then from process A to make process B as foreground. HTH Alex - |
| RobinZhou
Registered User |
Fri Oct 20 08:40:03 CDT 2006
Re:How to make a child process application active"Alex Blekhman" wrote: QuoteI think you should pass ID of process B (and may be main local COM server. So Process A cannot and should not communicate with process B directly. There is a weird thing that it works well on my machine with window 2003. I don't know why. Is there any system info setting about it? - |
| Alex
Registered User |
Fri Oct 20 08:53:07 CDT 2006
Re:How to make a child process application active
"RobinZhou" wrote:
Quote>I think you should pass ID of process B (and may be main Process A doesn't need to communicate with B. It's enough that COM server process will pass B's process ID back to A. Also, you can try to create process B in suspended state, then from process A, after it gave to B foreground rights, resume process B. I never tried it myself, though. I don't know why it works on Window 2003. Probably it has different implementation of windows manager. HTH Alex - |
