An external program window breaks the order of the windows

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

An external program window breaks the order of the windows

#1 Post 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?

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

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

#2 Post 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.
greetings by OHR
Jimmy

reganc
Posts: 257
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

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

#3 Post 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.
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

reganc
Posts: 257
Joined: Thu Jan 28, 2010 3:08 am
Location: Hersham, Surrey, UK
Contact:

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

#4 Post by reganc »

And as is usual, I found the answer soon after posting the previous email:

SetForegroundWindow()
Regan Cawkwell
Real Business Applications Ltd
http://www.rbauk.com

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#5 Post 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!

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

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

#6 Post by patito »

Hi

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

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

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

#7 Post 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
Attachments
TRunProcess.rar
(2.85 KiB) Downloaded 773 times

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#8 Post 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

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

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

#9 Post 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
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#10 Post 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?

Post Reply