In my vb6 program I need to use WaitForSingleObject on a separate shell launched program, kind a emulating a modal-style behavior. Now, while my vb6 app is waiting for this second program is does not re-paint, prevents the user from seeing their desktop if they wish to view it, and makes it seem as though the program has stopped responding (Which, I mean, technically it has). So I minimize the program for the brief period they're using the second program, the work flow works fine and I'm happy with that.

My problem appears once this second program has completed and I try to bring my vb6 program back up and to the front. It seems that I am unable to do so through simply maximizing the window state, BringWindowToTop(), ShowWindow(), SetWindowPos(), SetActivewindow(), SetForegroundWindow() or any combination of these. The only way I've been able to make my program come to the front is by setting it to Always On Top. I've tried looping the code until GetForegroundWindow and GetActiveWindow are the windows I expect them to be but unfortunately that doesn't seem to work. The code reports back that my program is the active window and also the foreground window but I can see that is not the case. Whatever window became active when I minimized my program is what remains in front.

My program has a MDIParent/child thing going on so I tried alternating the two of those to be the desired front form but changing that had no effect. I'm out of ideas and I really don't know why this won't work for me.

I think it's worth noting that although this problem happens the first time, subsequent launches of the secondary program have it returning just fine with no issue, which is especially frustrating. Code below.

Code:
hProcessID = Shell("""SecondProgram.exe"" print" + fileLoc, vbNormalFocus)
    
    
    If hProcessID <> 0 Then
        Call frmMDIChild.WaitForAppTerminate(hProcessID)
    End If

Public Sub WaitForAppTerminate(hProcID As Long)
   Dim hProcess As Long
   hProcess = OpenProcess(SYNCHRONIZE, 0, hProcID)

   If hProcess <> 0 Then
      frmMDIParent.WindowState = vbMinimized
      Call WaitForSingleObject(hProcess, INFINITE)
      BringWindowToTop frmMDIParent.hwnd
      ShowWindow frmMDIParent.hwnd, 3
      SetActivewindow frmMDIParent.hwnd
      SetForegroundWindow frmMDIParent.hwnd
      DoEvents
   End If
Any help or insight would be greatly appreciated!