[SOLVED] Application Focus in Windows 7 | Uniface Deployment | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

—  Results per page  —








— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters
For a group of consecutive words like 'end of support' use Match phrase

sp_Feed Topic RSS sp_TopicIcon
[SOLVED] Application Focus in Windows 7
07 Dec 2016
6:02 pm
Avatar
jruss
Member
Forum Posts: 3
Member Since:
07 Dec 2016
sp_UserOfflineSmall Offline

I’m looking for a way to move my Uniface desktop application to the top of the Windows OS Z-Order.  Preferably without using a third party tool.

 

Currently using Uniface 9.6.05.

08 Dec 2016
9:21 am
Avatar
diseli
Admin
Forum Posts: 810
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Could you provide more details about what exactly you would like to achieve? Do you want that your Uniface application is staying on top or are you looking for a way to bring the application to the front?

08 Dec 2016
4:02 pm
Avatar
RobM
Member
Forum Posts: 7
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

I’m curious as well.  Sometimes when a Uniface App starts it goes behind the current window and I have to “find” it.  Sometimes it’s on top but does not have focus.  9.6.05 here as well.

09 Dec 2016
4:00 pm
Avatar
jruss
Member
Forum Posts: 3
Member Since:
07 Dec 2016
sp_UserOfflineSmall Offline

I’m using the timeout function to log users out after a certain amount of inactivity.  Instead of just abruptly logging the user out though, I would like to give the user a chance to say they are still working in case they have unsaved work.  If the user has my Uniface application minimized or just another application in front of it on the desktop, I would like to push my application to the front and in focus for the user to see.

 

Thanks in advance,

Jared

09 Dec 2016
4:49 pm
Avatar
diseli
Admin
Forum Posts: 810
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

jruss said
I’m using the timeout function to log users out after a certain amount of inactivity.  Instead of just abruptly logging the user out though, I would like to give the user a chance to say they are still working in case they have unsaved work.  If the user has my Uniface application minimized or just another application in front of it on the desktop, I would like to push my application to the front and in focus for the user to see.

 

Thanks in advance,

Jared  

Hi Jared,

Thanks for the additional info.

You could use the Windows API User32 function SetWindowsPos (and call it with a C Call-Out signature) to bring the Uniface Application window to the front. I don’t have a ready-made sample for this at the moment, but I’ll try to plan some time next week to create one. Will keep you posted.

Hope this helps.

Daniel

13 Dec 2016
10:40 am
Avatar
diseli
Admin
Forum Posts: 810
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Hi Jared,

I did some tests and I could achieve the best results when I use the USER32 function ShowWindowAsync and SetForegroundWindow.

I’ve created a small sample that demonstrates the two functions in “action” (see the Community Sample “Bring Uniface application window to front”). The sample includes the form BRINGTOFRONT and 2 C Call-Out signatures (YRTL and USER32). The form features the button “Start” that will generate an asynchronous message after about 30 seconds (using the UTIMER component). And when the Asynchronous Interrupt trigger of the form is fired then the following code is executed:

newinstance “YRTL”, hYrtl
hWnd = hYRTL->uGetHwnd()
newinstance “USER32”, hUser32
hUser32->ShowWindowAsync(hWnd, SW_SHOWDEFAULT) ; constant SW_SHOWDEFAULT = 10
hUser32->ShowWindowAsync(hWnd, SW_SHOW)        ; constant SW_SHOW = 5
hUser32->SetForegroundWindow(hWnd)

The YRTL function ugethwnd will get the window handle of the Uniface application window that will be used with ShowWindowAsync and SetForegroundWindow.

Please note that I’ve created this sample using Uniface 9.7.03. But it should also work with any other Uniface 9.7 or 9.6 version.

Hope this helps.

Daniel

13 Dec 2016
10:46 am
Avatar
diseli
Admin
Forum Posts: 810
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

I’ve forgot to mention that not in all situations the Uniface application will be brought to the front. In case a menu of another application is open or the foreground window is locked then the Uniface application window will stay in the background and the icon in the Windows taskbar will flash. This is just normal Windows behavior.

13 Dec 2016
11:41 pm
Avatar
jruss
Member
Forum Posts: 3
Member Since:
07 Dec 2016
sp_UserOfflineSmall Offline

diseli said
Hi Jared,

I did some tests and I could achieve the best results when I use the USER32 function ShowWindowAsync and SetForegroundWindow.

I’ve created a small sample that demonstrates the two functions in “action” (see the Community Sample “Bring Uniface application window to front”). The sample includes the form BRINGTOFRONT and 2 C Call-Out signatures (YRTL and USER32). The form features the button “Start” that will generate an asynchronous message after about 30 seconds (using the UTIMER component). And when the Asynchronous Interrupt trigger of the form is fired then the following code is executed:

newinstance "YRTL", hYrtl<br /> hWnd = hYRTL-&gt;uGetHwnd()<br /> newinstance "USER32", hUser32<br /> hUser32-&gt;ShowWindowAsync(hWnd, SW_SHOWDEFAULT) ; constant SW_SHOWDEFAULT = 10<br /> hUser32-&gt;ShowWindowAsync(hWnd, SW_SHOW)        ; constant SW_SHOW = 5<br /> hUser32-&gt;SetForegroundWindow(hWnd)

The YRTL function ugethwnd will get the window handle of the Uniface application window that will be used with ShowWindowAsync and SetForegroundWindow.

Please note that I’ve created this sample using Uniface 9.7.03. But it should also work with any other Uniface 9.7 or 9.6 version.

Hope this helps.

Daniel  

Hi Daniel,

This worked perfectly.  I was having a lot of trouble getting the window handle and was unaware of the ugethwnd function.  

Thanks,

Jared

15 Dec 2016
9:10 am
Avatar
diseli
Admin
Forum Posts: 810
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

jruss said

Hi Daniel,

This worked perfectly.  I was having a lot of trouble getting the window handle and was unaware of the ugethwnd function.  

Thanks,

Jared  

 Hi Jared,

Thanks for your feedback. And I’m happy to hear that this is working for you.

Daniel

15 Dec 2016
11:50 am
Avatar
ulrich-merkel
Frankfurt/Germany
Member
Forum Posts: 1681
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

Good and easy solution, only one observation:

starting with a maximised window, the application reappears as non-maximised.

But I think this sideeffect (of SW_SHOWDEFAULT ??) can be tolerated;
I haven’t found a better option under those provided by MSoft

15 Dec 2016
2:27 pm
Avatar
ulrich-merkel
Frankfurt/Germany
Member
Forum Posts: 1681
Member Since:
01 Oct 2012
sp_UserOfflineSmall Offline

The following extension may help:

    hUser32->IsIconic(n_IsIconic, hWnd);
   if (n_IsIconic)
       hUser32->ShowWindowAsync(hWnd, SW_SHOWDEFAULT); showdefault
   endif
Forum Timezone: Europe/Amsterdam

Most Users Ever Online: 131

Currently Online:
15 Guest(s)

Currently Browsing this Page:
2 Guest(s)

Top Posters:

ulrich-merkel: 1681

Iain Sharp: 604

Theo Neeskens: 339

gianni: 249

rogerw: 232

lalitpct: 197

istiller: 195

Knut: 172

-GHAN-: 171

sochaz: 165

Member Stats:

Guest Posters: 3

Members: 5429

Moderators: 0

Admins: 8

Forum Stats:

Groups: 1

Forums: 62

Topics: 2011

Posts: 8670

Newest Members:

CarlaBiada, ulgopex, akyabfosikvu, emeliapokeuj, ofeenpe, azuokleb, etonuwahu, DennisovMn, SamuelLog, Dannypiorp

Administrators: admin: 23, Adrian Gosbell: 276, diseli: 810, Bob Maier: 3, Nico Peereboom: 60, Michael Rabone: 4, richiet: 406, JanCees: 28