Child process rejoining makes the Parent process start all over... How to avoid this? - child-process

I have a peculiar situation. This is a Python Question.
I start a parent process (say Process 123). It opens Window 1 (PySimpleGUI Window) and then on a button click opens Window 2 (say Process 456) which is another PySimple GUI Window). I also close Window 1 (Process 123) at that time.
Now, Window 2 (Process 456) at some point kicks of a child process (888) by design. I want the child process (888) to complete and comeback with a result for me to use within process (456). But my problem is when the child process joins back, it starts a brand new Parent process with Window 1 (999).
How do I make child process 888 to rejoin with Process 456 in Process 456's current state at that time?
How do I avoid a brand new Parent Process with Window 1 (999) being kicked off?
Is this some weird PySimple GUI behavior?
Regards,
Pradhip. S
I was expecting the child process to join back the parent process and not go start a new Parent Process.

Related

how to create window child window outside primary window

I've learned how to create a child window within the parent window, but I want to create a window outside the program's primary window. If I'm not mistaken, a window outside the primary one is still a child window, right? Does it have its own class that needs to be registered? I tried just making another window, but changing the arguments. I got some interesting results, but not a separate window.

How to detach IMFMediaSession / IMFTopologyNode from hwndVideo?

Reference How to Play Media Files with Media Foundation.
My main thread has a parent window. I created an EVR child window in the worker thread through MFCreateVideoRendererActivate(HWND hwndVideo, IMFActivate** ppActivate) as a video player. But now the problem is that when the parent window exits, the child window will receive the WM_DESTROY message, which triggers the CloseSession, and the player has WaitForSingleObject waiting for the close confirmation, there may be a few seconds of stuck.
So I look forward to a safe method of Detach hwndVideo. so after that, the worker thread does not depend on the window system and does not affect the main thread.
But the IMFTopologyNode or IMFActivate / IMFMediaSink documents have not reset the interface method of hwndVideo,and I tried using IMFTopology::RemoveNode to remove the MF_TOPOLOGY_OUTPUT_NODE nodes, and it had no effect
You could probably handle WM_DESTROY in parent window and hide and detach (SetParent) children preventing their immediate destruction. Either way, however, creating windows from worker threads is almost always a bad idea resulting in artifacts as mentioned. If you could change this behavior, it would result in more reliable design.

OpenEdge ABL UI Freeze window until Popup closes

I'm using OpenEdge ABL to create a window that will run a secondary window on the touch of a button. However I am trying to get the first/parent window to freeze while the child window is running and resume when the child window closes.
I attempted to use WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW on the parent window however this returned the error: Invalid widget handle used in WAIT-FOR statement. WAIT-FOR terminated (4122).
To run the child window I use:
RUN D:\adherenceEdit_12875-Win.w(cUserId,cShiftCode,dtDate).
Are you trying to make the child window modal?
I think you can look into using the TOP-ONLY or ALWAYS-ON-TOP attributes on the window, or make the child a dialog box.
I got around this was by adding:
DO WITH FRAME {&FRAME-NAME}:
Making the sensitivity of the buttons false meant that they would not be pressed while the child window was running.
ASSIGN CURRENT-WINDOW:SENSITIVE = FALSE.
RUN D:\adherenceEdit_12875-Win.w(INPUT cUserId,
INPUT cShiftCode,
INPUT dtDate).
After the child was closed the parent window continues running and resets the buttons sensitivity allowing them to be pressed
ASSIGN CURRENT-WINDOW:SENSITIVE = TRUE.
END.
I'm not sure if this is the most efficient way to do this and #nwahmaet's answer may have provided a more efficient method.
I like to do this by hiding the Main Window while the Popup is opened...
// Replace the C-Win to window's name - Not required to specify the frame
C-Win:VISIBLE = FALSE.
RUN My_Program.w.
C-Win:VISIBLE = TRUE.

how to start process minimized on windows with factor

I have an executable which I call from my factor program (with ) a few times in a second. And it always pops up and becomes the active window even if the listener is in the background. How could I start it minimized or just not as the active window? Is there a paramater of the 'process' that can be set this way?

Foreground Vs Active window

In Windows, what is the difference between foreground and active window? To be specific, under what circumstances can a foreground window not be an active window? If the 2 terms are referring to the same concept why there're 2 terms.
The msdn documentation here mentions "clicking a window, or by using the ALT+TAB or ALT+ESC key combination" makes a window active as well as foreground. There is nothing explicitly about the difference between the 2 terms.Check MSDN.
The active window (the result of GetActiveWindow()) is the window attached to the calling thread that gets input. The foreground window (the result of of GetForegroundWindow()) is the window that's currently getting input regardless of its relationship to the calling thread. The active window is essentially localized to your application; the foreground window is global to the system.
For example, if a window belonging to another process is the foreground, calling GetActiveWindow() from within your own process will return NULL.
I believe that it's true that being the foreground window implies being the active window, but the converse is not true. Also note that in modern Windows, applications generally cannot use SetForegroundWindow() to steal focus from another process (unless that process has explicitly given permission via AllowSetForegroundWindow).
I find the description in MSDN a bit confusing as well but here is my revised take:
First a foreground and background window have nothing to do with active windows, it has to do with threading, see below. So it is technically possible to have background window as an active window however it is confusing and the system doesn't do this for you, instead your app needs to call e.g. SetWindowPos to make the background window active.
The system can only have one active top-level window at a time, the system will activate the top-level window if you are working on a child window. All input is then directed to the active window and then normally passed to the child window.
/----------------------\
| |
| FOREGROUND WINDOW |--\
| | |
\----------------------/ |
| BACKGROUND WINDOW |
\-----------------------/
/----------------------\
| |
| ACTIVE WINDOW |--\
| | |
\----------------------/ |
| BACKGROUND WINDOW |
\-----------------------/
From MSDN
Active Window
An active window is the top-level window of the application with which the user is currently working. To allow the user to easily identify the active window, the system places it at the top of the z-order and changes the color of its title bar and border to the system-defined active window colors. Only a top-level window can be an active window. When the user is working with a child window, the system activates the top-level parent window associated with the child window.
Foreground/Background
Each process can have multiple threads of execution, and each thread can create windows. The thread that created the window with which the user is currently working is called the foreground thread, and the window is called the foreground window. All other threads are background threads, and the windows created by background threads are called background windows.

Resources