Bring application to front

This forum is for eXpress++ general support.
Message
Author
skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Bring application to front

#1 Post by skiman »

Hi,

I have a startup application which starts my main application via runshell.

As soon as user entered his login credentials in the startup application, I send it to the main application and this continues.

This is working correct, but my main application doesn't come to front.

The main application is waiting for a file to proceed. As soon as it sees the file, it creates his main window. In the avel of the dcread I have a call to a tofront(cTitle) funtion which is as follows:

Code: Select all

	
function tofront(cTitle)
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 nil
The window handle is found, but the application doesn't come to front. In the Windows taskbar, the application is 'flickering' when the tofront() function is executed.

Any ideas?
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Bring application to front

#2 Post by rdonnay »

Do you close the login window before the main application is started?
The eXpress train is coming - and it has more cars.

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

Re: Bring application to front

#3 Post by Auge_Ohr »

skiman wrote:I have a startup application which starts my main application via runshell.
did you try RunShell() with Windows 10 ?

i recommend to use Pablos Trunprocess
Trunprocess
ot4xb.public
28. Juli 2011 -> Start Thread

Answer Pablo ( latest Version )
16. April 2013
skiman wrote:The window handle is found, but the application doesn't come to front.
In the Windows taskbar, the application is 'flickering' when the tofront() function is executed.
hm ... does it work on Win XP but not on Win 8 / 8.1 ?
try other Combination

Code: Select all

         ShowWindow( nHwnd, SW_RESTORE )
         ShowWindow( nHwnd, SW_SHOWNORMAL )
         BringWindowToTop( nHwnd )
         SetForegroundWindow( nHwnd )
greetings by OHR
Jimmy

skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Bring application to front

#4 Post by skiman »

rdonnay wrote:Do you close the login window before the main application is started?
No, The login application starts the main application with runshell as soon as it starts. The main application is processing some data in the background when the login dialog appears. When the user entered his login details, there is a small file written in the main directory, and the login application ends.
The main application is waiting for that small file, and then proceeds as soon as everything is initialised.

Mail goal of this setup:
- Login application will load much faster. This is about 500 K. where the main application is 50 M.
- The time it takes for a user to enter his login details, the main application is loaded and is initializing.
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Bring application to front

#5 Post by skiman »

Hi Jimmy,

I tried with another combination as you suggested. The result remains the same.
Best regards,

Chris.
www.aboservice.be

messaoudlazhar
Posts: 42
Joined: Mon Dec 23, 2013 2:10 pm
Contact:

Re: Bring application to front

#6 Post by messaoudlazhar »

What is the syntax that you used in runshell ?

skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Bring application to front

#7 Post by skiman »

messaoudlazhar wrote:What is the syntax that you used in runshell ?
runshell( "autologon test.txt" , "count.exe" , .T. , .F. )

The main cause of this problem is that the logon application is getting focus at startup. It has the same effect as starting an application as notepad, and then clicking in the taskbar to set the focus to another application.

I need something to bring my application to front at the moment it can proceed.
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Bring application to front

#8 Post by rdonnay »

No, The login application starts the main application with runshell as soon as it starts.
I think this is the cause of the problem.
I wrote a sample program many years ago (..\exp19\samples\xppload.prg) to deal with the problem of slow loading programs.
It works in the same way except with no login screen.
I don't think that it has the same problem with setting the window to the front.

Is there a way that you can reproduce this behavior in a small sample program?
The eXpress train is coming - and it has more cars.

skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Bring application to front

#9 Post by skiman »

Hi Roger,

i will check your sample program. If I don't succeed, I will post a test for this.
Best regards,

Chris.
www.aboservice.be

skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Bring application to front

#10 Post by skiman »

Hi Roger,

If you add a msgbox() to the xppload sample, you get the same result.
In attachment I send you a modified xppload.prg and a modified xdemo.prg.
If you start 'xppload xdemo.exe' you will see my problem.

With your xppload you 'animate' the user, but there is no time benefit. I want to use the time the user spends on the login procedure, to start my application and to initialize everything. In that initializing there are checks on environment variables, installation of fonts, registry checks, checking for existing dbf files, ... The load of the application and the initializing takes about 5 seconds on a network. If the login screen appears in a second, and the user proceeds after 5 seconds, he don't have to wait for any initializing. This way there is a real time benefit.
Attachments
Xppload.zip
(17.06 KiB) Downloaded 687 times
Best regards,

Chris.
www.aboservice.be

Post Reply