The focus of the window is lost after ALT + TAB

Post found bugs and possible workarounds.
chelonet
Argentina
Posts: 7
Joined: 19 Apr 2017, 15:28
Location: Argentina

The focus of the window is lost after ALT + TAB

Post by chelonet » 11 Sep 2017, 21:17

Hi,
I tested this in TD 6.1, 6.2 and 7.0 (In Windows 7. In Windows XP operating properly)

In a TD application, Form1 calls Form2 and Form2 calls Form3 (always with SalCreateWindow (FormX, hWndForm)), and then I go to another application with ALT + TAB and then return to the TD application. In this case, Form3 loses focus, and remains on Form1.

Attached is a test case.
FrmLostFocus.zip
In the example, there is a keyboard accelerator in each window where you press Esc, running SalDestroyWindow (hWndForm). So, if I'm on Form3, then I go to another application with ALT + TAB, then go back to the TD application and press ESC with the intention of closing Form3, erroneously closes Form1 and therefore the entire application.

Is this a bug, or is there any configuration so that it does not happen ?
You do not have the required permissions to view the files attached to this post.

H3PO4
Germany
Posts: 25
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: The focus of the window is lost after ALT + TAB

Post by H3PO4 » 12 Sep 2017, 07:11

Hi chelonet,

just downloaded your sample and tested on Windows7 Enterprise 64bit, TD 62 SP1. (from IDE and as .EXE)

Everything seems to be fine. After returning from another App (Outlook in this case) and pressing Escape FORM3 closes, another Escape closes FORM2 and so on.

Do you have some special settings with your Windows installation or is your Windows running inside a VBOX?

Best regards
Henning

EwaldP
Austria
Posts: 41
Joined: 07 Mar 2017, 08:00
Location: Austria

Re: The focus of the window is lost after ALT + TAB

Post by EwaldP » 12 Sep 2017, 07:41

That is interesting. There was a bug in TD6.1 that a application/form / datafield lost the focus when switching back from another application. But this bug was fixed in TD 6.1 SP5 and above. I've tried your sample and the same behaviour as you described. That's strange because in our application (TD 6.3 SP2) a datafield doesn't loose the focus when switching back from another application. As soon as I have time, I will try to figure out the difference.

Ewald
Ewald P. Palmetshofer
EDV-Hausleitner GmbH
4020 Linz
www.edv-hausleitner.at

chelonet
Argentina
Posts: 7
Joined: 19 Apr 2017, 15:28
Location: Argentina

Re: The focus of the window is lost after ALT + TAB

Post by chelonet » 12 Sep 2017, 18:14

Hi Henning, Ewald,
Thank you for taking the test and responding.
I do not understand why it does not happen to you.
The version I have of windows is standard, and it happens to me on my PC, on all the PCs of my colleagues, and on all the clients (which are a few).

Viewing the title bar of the window, it identifies which one has the focus. When I return from another window (WITHOUT TOUCHING ANYTHING), you can see that the focus has FORM 1.

When you return from the other application, you do not have to click on FORM 3, but you have to press ESC directly. Do you do this?

H3PO4
Germany
Posts: 25
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: The focus of the window is lost after ALT + TAB

Post by H3PO4 » 13 Sep 2017, 06:20

Hi chelonet,

no, no clicks after Alt+TAB. And after switching back I can see the focus is on FORM3.

I tried this with different themes, every theme works as expected.

Greetings
Henning

chelonet
Argentina
Posts: 7
Joined: 19 Apr 2017, 15:28
Location: Argentina

Re: The focus of the window is lost after ALT + TAB

Post by chelonet » 13 Sep 2017, 14:17

Hi,
Attached is a video, where the behavior is displayed.
When in FORM 3, it is displayed that it has the focus, and the FORM 1 button is gray.
It is visualized that when doing ALT + TAB and going to another application (Explorer), when returning the focus has FORM 1, and the button of this form is in yellow (focus).
Then press ESC once and close the entire application (because it takes the ESC of FORM 1, and the other forms are childs)
At the end, you see the Windows version (Professional 7, 64 bit).

Any Suggestions?
20170913_110007.zip
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 263
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: The focus of the window is lost after ALT + TAB

Post by Dave Rabelink » 15 Sep 2017, 13:39

My guess is that it is not a TD defect, but a Windows feature.
When a form is owned (created having a parent), the form is not displayed on the taskbar.
As the first form is created unowned (no parent), this window will be the application window and will be displayed on the taskbar.

The ALT-TAB behaviour will use the focussed form which is unowned by default, so ALT-TAB back will refocus that form.

I tried to fix this by forcing each form to have the WS_EX_APPWINDOW extended style.

See MSDN:
https://msdn.microsoft.com/en-us/library/aa969325.aspx
(section on Managing Taskbar Buttons)

Having this style, an owned form will be shown on the taskbar and will be present in the ALT-TAB list.

Here the source:
FrmLostFocus_TD51.zip
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

chelonet
Argentina
Posts: 7
Joined: 19 Apr 2017, 15:28
Location: Argentina

Re: The focus of the window is lost after ALT + TAB

Post by chelonet » 18 Sep 2017, 15:57

Thanks Dave.
I appreciate your answer.
The explanation is clear, and solves the problem ... but I do not know if I will apply it.

What I notice with your solution, is that each form appears in the taskbar.
In the old Centura it worked OK the Alt + TAb, and with TD changed the behavior (in Centura, each form also appeared on the taskbar).

I do not understand because without having to force the style of each form, it does not happen what naturally should happen. I would like to find another solution.

Thanks !!!

H3PO4
Germany
Posts: 25
Joined: 10 Mar 2017, 07:53
Location: Rohlstorf, Germany

Re: The focus of the window is lost after ALT + TAB

Post by H3PO4 » 19 Sep 2017, 11:27

Hi Chelonet, hi Dave,

I do understand the usage of the styleflag.

What I don't understand is, that on my workstation (see configuration above), everything works ok without setting the style.
There must be some configuration things inside window (I didn't set them), that do the trick.

Regards vom Hamburg, Germany
Henning

chelonet
Argentina
Posts: 7
Joined: 19 Apr 2017, 15:28
Location: Argentina

Re: The focus of the window is lost after ALT + TAB

Post by chelonet » 19 Sep 2017, 14:35

Hi H3PO4,
Good point.
In my case, I use Windows 7 Profesional (not Enterprise) 64 bits (test with and without Aero)
Test in TD 6.1 SP3/SP6, 6.2 and 7.0 (I can not get 6.1 SP1), in Exe and IDE.
And in all cases the same thing. (In Centura 1.5.1 did not happen).

I do not understand either...

Opsss, while writing this, I came up with a test on a PC with another operating system, in this case Windows Server 2003 R2 Enterprice (TD 6.1 SP3), and it worked correctly !!!
What's more, in the taskbar a single window appears (Form1), and when you do ALT + TAB, it appears as the window name to return: Form3. Unlike Windows 7, when you do ALT + TAB, it appears as the window name to return: Form1
With that, effectively Windows has something to do.

chelonet
Argentina
Posts: 7
Joined: 19 Apr 2017, 15:28
Location: Argentina

Re: The focus of the window is lost after ALT + TAB

Post by chelonet » 19 Sep 2017, 15:17

Continuing with the previous post:
I tested it on Windows Server 2008 SP1 standard and it worked OK.
I noticed that in the two Servers I tried, they look like the "Windows Clasic" theme.
So in Windows 7 I was testing with "Windows Basic", I changed the theme to "Windows Clasic", and it worked OK !!!!

H3PO4, do you happen to use the "Windows Clasic" theme?

It's amazing, but then is there a different behavior with the TD ALT + TAB depending on the Windows theme?
Any explanation?

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 263
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: The focus of the window is lost after ALT + TAB

Post by Dave Rabelink » 20 Sep 2017, 14:29

There are differences in functionality of ALT-TAB between Windows versions.
But also differences within Windows themes.

Also, the way ALT-TAB works and is visualized can be changed in the options.

Here some info on the web about this:

http://www.makeuseof.com/tag/get-more-f ... now-about/
https://blogs.msdn.microsoft.com/oldnew ... 0/?p=21793
https://www.online-tech-tips.com/window ... b-windows/

Maybe playing around with these settings makes the difference here.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “Bug Reports”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests