Dave Craggs 7 Posted April 13, 2023 Hi I have a VCL application. Some of the forms stay visible when switching between windows desktops. The main form doesn't. Couldn't see an obvious property causing ths. Any ideas? Share this post Link to post
PeterBelow 238 Posted April 13, 2023 42 minutes ago, Dave Craggs said: Hi I have a VCL application. Some of the forms stay visible when switching between windows desktops. The main form doesn't. Couldn't see an obvious property causing ths. Any ideas? Is Application.MainformOnTaskbar set to true or false in the DPR file? Or are you using an ancient Delphi version that does not support this property? Do any of the misbehaving forms override the CreateParams method? Share this post Link to post
Dave Craggs 7 Posted April 13, 2023 Application.MainFormOnTaskbar := True; Delphi 10.3 at the moment Share this post Link to post
Remy Lebeau 1394 Posted April 13, 2023 (edited) 4 hours ago, Dave Craggs said: Some of the forms stay visible when switching between windows desktops. The main form doesn't. Are you switching between actual Win32 desktop, or virtual desktops? They are very different things. A window cannot be moved between Win32 desktops, it exists only in the desktop in which it was created. A window can be freely moved between virtual desktops, either by user action, or by code calling the IVirtualDesktopManager.MoveWindowToDesktop() method. Note, a window can appear in multiple desktops: https://learn.microsoft.com/en-us/answers/questions/611694/windows-virtual-desktops Quote Type Win + Tab to show up the Multiple Desktops panel also showing windows of the current desktop. Right click on one of them and you can choose either "Show this window on all desktops" or "Show windows from this app on all desktops". You can now switch desktop and they'll stick to the screen. If you choose the 2nd option, it will remember your choice even if you close all windows from the app at one point. Another interesting tidbit: https://superuser.com/questions/950960/pin-applications-to-multiple-desktops-in-windows-10 Quote Every window with WS_EX_TOOLWINDOW attribute is visible on all desktops Do your Forms in question have their BorderStyle set to bsToolWindow or bsSizeToolWin, by chance? Edited April 13, 2023 by Remy Lebeau Share this post Link to post
Dave Craggs 7 Posted April 14, 2023 Thanks for the reply. These are the windows 10 virtual desktops. Border style is bsSizable Attribute WS_EX_TOOLWINDOW is not present in my code. Share this post Link to post
Remy Lebeau 1394 Posted April 14, 2023 5 hours ago, Dave Craggs said: Attribute WS_EX_TOOLWINDOW is not present in my code. Maybe not in your code, but who knows what the VCL does internally. MainFormOnTaskbar=true does some really funny things. In any case, have you tried verifying with GetWindowLongPtr(GWL_EXSTYLE) or Spy++ or equivalent that your affected windows don't actually have that style when you are not expecting it? Just a thought. Can you produce a bare-bones test project with minimal code that reproduces the behavior? Share this post Link to post
David Heffernan 2345 Posted April 15, 2023 22 hours ago, Remy Lebeau said: Maybe not in your code, but who knows what the VCL does internally. MainFormOnTaskbar=true does some really funny things. In any case, have you tried verifying with GetWindowLongPtr(GWL_EXSTYLE) or Spy++ or equivalent that your affected windows don't actually have that style when you are not expecting it? Just a thought. Can you produce a bare-bones test project with minimal code that reproduces the behavior? MainFormOnTaskbar doesn't do anything very funny, and it doesn't make your window be a tool window. Share this post Link to post