Passing window to a different process?
-
I have two programs, and I need to have a special window open whenever one or both of them are loaded. It's working pretty well, but I've run across a problem: if I load program 1, then program 2, then close P2, then close P1, it works fine (the window isn't destroyed until the last program exits), but if I load P1, then P2, then close P1, the special window is destroyed (because P1 was the program that spawned it). Is there any way to pass the special window from P1 to P2, so closing P1 doesn't close the that window? I can't just recreate the special window, because then it loses its position on the taskbar (moves to the end of the list of open programs). Thanks!
-
I have two programs, and I need to have a special window open whenever one or both of them are loaded. It's working pretty well, but I've run across a problem: if I load program 1, then program 2, then close P2, then close P1, it works fine (the window isn't destroyed until the last program exits), but if I load P1, then P2, then close P1, the special window is destroyed (because P1 was the program that spawned it). Is there any way to pass the special window from P1 to P2, so closing P1 doesn't close the that window? I can't just recreate the special window, because then it loses its position on the taskbar (moves to the end of the list of open programs). Thanks!
When P1 starts, check for the existance of the special window and create it if necessary. Save the window handle for later. When P2 starts, check for the existance of the special window and create it if necessary. Save the window handle for later. When P1 ends, if it has a valid window handle and P2 is not running, close the special window. When P2 ends, if it has a valid window handle and P1 is not running, close the special window. Will that work?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
I have two programs, and I need to have a special window open whenever one or both of them are loaded. It's working pretty well, but I've run across a problem: if I load program 1, then program 2, then close P2, then close P1, it works fine (the window isn't destroyed until the last program exits), but if I load P1, then P2, then close P1, the special window is destroyed (because P1 was the program that spawned it). Is there any way to pass the special window from P1 to P2, so closing P1 doesn't close the that window? I can't just recreate the special window, because then it loses its position on the taskbar (moves to the end of the list of open programs). Thanks!
I don't believe a window can survive it's parent process. If that is true then you need the "special window" to be a separate process. Then i believe you can just make the special process a "single instance" process by using a mutex.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
-
I don't believe a window can survive it's parent process. If that is true then you need the "special window" to be a separate process. Then i believe you can just make the special process a "single instance" process by using a mutex.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
-
When P1 starts, check for the existance of the special window and create it if necessary. Save the window handle for later. When P2 starts, check for the existance of the special window and create it if necessary. Save the window handle for later. When P1 ends, if it has a valid window handle and P2 is not running, close the special window. When P2 ends, if it has a valid window handle and P1 is not running, close the special window. Will that work?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
That's exactly what I'm doing already. The problem occurs when closing P1 but P2 is still running: the special window is closed anyway (which appears unavoidable unless a separate process is used for the special window).
So are you saying that P1 is closing the special window without first checking to see if P2 is still running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
Yes Why dont you simply *hide* P1 as if it was closed? Another option is to inject the window into explorer.exe this way it wont die with P1. Check CreateRemoteThread Papa while (TRUE) Papa.WillLove ( Bebe ) ;
-
So are you saying that P1 is closing the special window without first checking to see if P2 is still running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
We're trying to avoid that, making it as clean as possible. But, if there's no decent way around it, then we might end up doing that after all.
Sorry that Anonymous post was me... i timed out, had to actually do some work :laugh: "Clean" is in the eye of the beholder. My first thought is that a Single Instance process for the special window would produce the "Simplest" solution. I always like simple. Of course I don't have the complete context of your problem so...
"No matter where you go, there your are." - Buckaroo Banzai
-pete
-
Sorry that Anonymous post was me... i timed out, had to actually do some work :laugh: "Clean" is in the eye of the beholder. My first thought is that a Single Instance process for the special window would produce the "Simplest" solution. I always like simple. Of course I don't have the complete context of your problem so...
"No matter where you go, there your are." - Buckaroo Banzai
-pete
Well, basically I'm trying to force two different programs to appear as one program on the taskbar, but two separate programs in the alt-tab window. I'm currently doing it by making the two programs not show up on the taskbar, and using a special window and the ITaskbarList interface to make an entry on the taskbar that doesn't show up in the alt-tab window.
-
No; let me show you some psuedo-code to illustrate:
P1_OnExit() { if(!exists(P2)) close(specialwindow) //window is closed, like it should be } //P1 closes //The special window is closed, even if P2 still exists
It looks as though the
exists()
function is not returning the correct status of P2. On the other hand, I may be making an incorrect assumption about the "special window." Reading through the other replies to this post, I was assuming it was a separate process (since the word spawn) was used. If it is indeed just a window that is "owned" by P1, my posts are wrong.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
Well, basically I'm trying to force two different programs to appear as one program on the taskbar, but two separate programs in the alt-tab window. I'm currently doing it by making the two programs not show up on the taskbar, and using a special window and the ITaskbarList interface to make an entry on the taskbar that doesn't show up in the alt-tab window.
-
Probably a stupid question, but... Why not just One process that looks like One process because it is One process? :-D
"No matter where you go, there your are." - Buckaroo Banzai
-pete
-
Is that "Too big" as in the projects are too big, or in the process memory is too big? If it's the later, then I wouldn't consider that an issue as both programs will have to be in memory regardless. In fact, it may be slightly less memory as there is no overhead for the second process (not mention code being used for communication). If it's the former, then you may want to break up the application into dlls that are more easily managed. -- Joel Lucsy
-
Is that "Too big" as in the projects are too big, or in the process memory is too big? If it's the later, then I wouldn't consider that an issue as both programs will have to be in memory regardless. In fact, it may be slightly less memory as there is no overhead for the second process (not mention code being used for communication). If it's the former, then you may want to break up the application into dlls that are more easily managed. -- Joel Lucsy