Jump to content
Dave Craggs

Forms showing on multiple desktops

Recommended Posts

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
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
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 by Remy Lebeau

Share this post


Link to post

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×