Page 1 of 1

An external program window breaks the order of the windows

Posted: Thu Nov 29, 2018 8:32 pm
by Eugene Lutsenko
The progress bar of the external program brings the current window to the background. How to make the current window does not disappear in the background, and remained on the screen?

Re: An external program window breaks the order of the windo

Posted: Thu Nov 29, 2018 11:25 pm
by Auge_Ohr
Eugene Lutsenko wrote:The progress bar of the external program brings the current window to the background. How to make the current window does not disappear in the background, and remained on the screen?
if you have a Top-Window (XbpDialog) you can use

Code: Select all

   oDialog:alwaysOnTop- := .T.
but now a MsgBox() or other Windows will also hide by your Dialog and User will not recognize it :!:

---

what about run external App minimized :?:
if Progressbar use ITaskbarList Interface , like DXE_Progressbar(), you get Progress Animation in Taskbar Icon

while Runshell() have no Option like SW_MINIMIZE i use this

Code: Select all

DLLFUNCTION ShellExecute( nHWND, cOperation, cFile, cParms, cDirectory, nOpenMode  );
            ALIAS ShellExecuteA USING OSAPI FROM SHELL32.DLL

   * #define SW_HIDE             0
   * #define SW_NORMAL           1
   * #define SW_SHOWMINIMIZED    2
   * #define SW_SHOWMAXIMIZED    3
   * #define SW_MAXIMIZE         3
   * #define SW_SHOWNOACTIVATE   4
   * #define SW_SHOW             5
   * #define SW_MINIMIZE         6
   * #define SW_SHOWMINNOACTIVE  7
   * #define SW_SHOWNA           8
   * #define SW_RESTORE          9
   * #define SW_SHOWDEFAULT      10

   lSuccess := ShellExecuteA( APPDESKTOP() :GetHWND(), ;
                              "open", ;
                              cPath + cFile, ; // full path
                              cParameter, ;
                              CURDIR(), ;     // where to run EXE
                              nSW )  // here SW_* Constante
   DO CASE
      CASE lSuccess > 32
         Retvar := .T.

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 2:33 am
by reganc
Eugene Lutsenko wrote:The progress bar of the external program brings the current window to the background. How to make the current window does not disappear in the background, and remained on the screen?
I have a similar problem.

We have a process that calls a browser on the users PC using ShellExecuteA as Jimmy showed.

At this point we wait for a response to be returned from the browser. We receive the response correctly but the browser has taken the focus from our application and I would like to restore focus back to our application.

I seem to remember seeing something about bringing an application back to the foreground but I am having trouble locating it at the moment.

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 3:35 am
by reganc
And as is usual, I found the answer soon after posting the previous email:

SetForegroundWindow()

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 4:20 am
by Eugene Lutsenko
So far (temporarily) I have solved this problem so that just removed the progress bar of the external program. But actually, he's needed. I'll try to keep my window in the foreground with SetForegroundWindow (). Thank you!

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 12:39 pm
by patito
Hi

I recommend using trunprocess , it has many options
attached prg, use ot4xb

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 12:42 pm
by patito
Hi

I recommend using trunprocess , it has many options
attached prg, use ot4xb
example
local oProcess := TRunProcess():New()
oProcess:cAppName := NIL
oProcess:cParams := NIL
oProcess:cCmdLine := "java -jar FocusWsdian.jar " + alltrim(LcP2)

oProcess:lUseShowWindow := .T.
oProcess:wShowWindow := oProcess:swHide

if oProcess:Start()
while !oProcess:Wait( 500 ) // Wait 0,25 seconds
enddo
oProcess:Release()
endif

return .T.

Best Regard
Héctor

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 4:42 pm
by Eugene Lutsenko
I must admit that I do not understand how to apply SetForegroundWindow() to the first plan window does not go to the background when you run an external program. I looked at the application of this feature in Express, but did not understand how I can use it for this purpose. Could someone please give a simple working example that could be compiled

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 5:25 pm
by Auge_Ohr
Eugene Lutsenko wrote:I must admit that I do not understand how to apply SetForegroundWindow() to the first plan window does not go to the background when you run an external program.
you need more than 1 API Call

Code: Select all

PROCEDURE BringToFront(oDialog)
LOCAL cTitle  := oDialog:Title
LOCAL hWndDlg := DllCall( "User32.dll", DLL_STDCALL, "FindWindowA", 0, cTitle )
   IF !( hWndDlg == 0 )
      DllCall( "User32.dll", DLL_STDCALL, "SetForegroundWindow", hWndDlg )
      DllCall( "User32.dll", DLL_STDCALL, "BringWindowToTop", hWndDlg )
      DllCall( "User32.dll", DLL_STDCALL, "ShowWindow", hWndDlg, 1 )
      DllCall( "User32.dll", DLL_STDCALL, "UpdateWindow", hWndDlg )
   ENDIF
RETURN

Re: An external program window breaks the order of the windo

Posted: Fri Nov 30, 2018 9:18 pm
by Eugene Lutsenko
Jimmy! Can you compile my system on your computer? Would you like to install the Eidos system on your computer and try to do it? I can communicate with you via Skype and TeamViewer. I could show you the system. You interested?