Lazarus

Programming => LCL => Topic started by: FRex on December 25, 2018, 06:52:13 am

Title: WindowState wsMaximized puts the window at end of Alt + Tab list on Window 10
Post by: FRex on December 25, 2018, 06:52:13 am
So I'm starting my program with a maximized form using WindowState set to wsMaximized, either in FormCreate, FormShow or in Object Inspector in the IDE.

All of these cause the newly created maximized window to be in focus, on top of other windows, maximized (so far it's all okay) but at the end of 'tab rotation' list (hold Alt and press Tab once to see the windows listed up, all other programs would be first, Lazarus made ones are last if they were maximized on start up).

By that I mean that if I then press Alt + Tab the new window is at the end instead of being first as it should be. Because of that if I just tap Alt + Tab once and then again I'm not back at the window of my program as I should be.

This is on Windows 10, Lazarus 1.8.4 r57972 FPC 3.0.4 x86_64-win64-win32/win64 but I had this Alt-Tab thing for a while now, it's not new at all.

It works properly for non Pascal applications that 'remember' that they were maximized (Firefox, Notepad++, VS Code, etc.).

Replacing second parameter of ShowWindow with SW_MAXIMIZE in this example also doesn't have this issue (not that I'm familiar with WinAPI or how LCL on win32 works but I'm just saying ...): https://docs.microsoft.com/en-us/windows/desktop/learnwin32/your-first-windows-program .

I run Lazarus IDE with Anchordockingdsgn so it's a single window and it also suffers from this problem (which I guess makes sense since Lazarus is written in LCL itself).

Even worse - so does a program called Pazera Audio Extractor whose exe has string 'Embarcadero Delphi for Win64 compiler version 28.0 (21.0.17707.5020)' in it so it seems to have been made via Delphi/VCL and not Lazarus/LCL.

So is this intentional behavior and working the same in LCL and VCL?

This also happens only once, on launching maximized. If I launch a 'normal' window and maximize it myself via the Windows GUI like any other window or in Pascal code then it's fine. It also 'fixes' itself after first time, e.g. if I once Alt + Tab or even just pick from task bar my program to get focus back to my Lazarus window it's going to work fine from there on, it's just that starting a maximized window gets put at the end of that Alt + Tab list instead of at the front. Non-maximized windows themselves work fine and as all other windows with regards to this alt tab list too.

It's really bizarre since no other programs made in other framework do that (Windows own 'File Explorer', WinAPI, Qt, GTK+, Electron - they all put new maximized window first in that tab list) and it's getting in the way of my muscle memory because with all other programs that start maximized I can: start them, do something in them, tap Alt + Tab once to then do something in the window I was using just before that, tap Alt + Tab again and be back in that newly launched program again to continue. But with my program made in Lazarus this flow is broken because the maximized Window is at the end of that list so I need to use arrow or tap Tab many times while holding Alt.

Is there a way to maximize window and have it be first in that 'tab rotation' list or do I need to set some other style/flag? Am I missing something (I just use Lazarus for one personal program and recreationally)?

Googling about this for Lazarus and Delphi and searching this forum didn't help. I didn't find anything mentioning this issue specifically, just other Alt + Tab stuff like questions about switching between Lazarus IDE windows, some GTK issue, putting a Delphi window intentionally at end of that list, etc.
Title: Re: WindowState wsMaximized puts the window at end of Alt + Tab list on Window 10
Post by: ASerge on December 25, 2018, 11:24:17 am
So I'm starting my program with a maximized form using WindowState set to wsMaximized, either in FormCreate, FormShow or in Object Inspector in the IDE.
...
Confirm the problem in Windows 10 (1803).
Does not reproduced in Windows 7.
Setting wsMaximized in FormActivate also solves the problem.
Use the workaround and add the problem to bugtracker (https://bugs.freepascal.org).
Title: Re: WindowState wsMaximized puts the window at end of Alt + Tab list on Window 10
Post by: FRex on December 25, 2018, 06:44:02 pm
Quote
Confirm the problem in Windows 10 (1803).
Does not reproduced in Windows 7.
My Windows 10 is 1809, the 'October' update (I got that update in December) but this has been a problem for a while (easily a year or a year and a half, first commit to my program is April 2017 and it might have been there already). I never used Lazarus programs on Windows 7, 8 or 8.1 so I can't say.

Quote
Setting wsMaximized in FormActivate also solves the problem.
Thanks for that one. That does work but it has minor problems like a seeming black flicker inside the window (I think due to work I do in FormCreate and FormShow and/or the few controls I have on my form because there's no visible flicker in a Form made in an empty project, I'll try code around it or just keep proper alt-tabbing at the cost of having that flicker) and if I do SetFocus on a widget in FormShow the problem with alt tab order still happens (so I moved the SetFocus to FormActivate too).

Quote
Use the workaround and add the problem to bugtracker.
Just please remember Delphi/VCL seems to do it too (Pazera Free Audio Extractor does at least and it seems to be built with Delphi). I know Lazarus and LCL try to be very compatible with Delphi and VCL.
TinyPortal © 2005-2018