Jump to content
PeterPanettone

Bringing the IDE automatically to the foreground?

Recommended Posts

One thing that has been annoying me for a long time: If you double-click a .DPR file in the File Explorer, it is loaded in the IDE, but the IDE is not brought to the foreground!

 

Can anyone confirm this - and is there a way to fix this problem?

Share this post


Link to post

Does this happen when the IDE is already open, when it must be started or in both cases?

Share this post


Link to post
3 minutes ago, dummzeuch said:

Does this happen when the IDE is already open

It happens when the IDE is already open but in the background (i.e., not in the foreground, not minimized).

Share this post


Link to post
1 hour ago, PeterPanettone said:

It happens when the IDE is already open but in the background (i.e., not in the foreground, not minimized).

Since several Windows versions an application running in background (= not having the input focus) cannot simply push itself into the foreground anymore because it thinks itself soo much more important than what the user may currently be working with. Instead it flashes its taskbar button to inform the user that it requires its attention. Does that not happen in your scenario?

  • Like 1

Share this post


Link to post

That are the documentation for the SetForegroundWindow ... https://learn.microsoft.com/it-it/windows/win32/api/winuser/nf-winuser-setforegroundwindow

 

I think the the link view it in Italian (my language) ... but you can easy make a search in your language.

 

Of course this is for an application, but the IDE is an application so the rules are those.

Bye

Edited by DelphiUdIT

Share this post


Link to post
1 hour ago, PeterBelow said:

Since several Windows versions an application running in background (= not having the input focus) cannot simply push itself into the foreground anymore because it thinks itself soo much more important than what the user may currently be working with. Instead it flashes its taskbar button to inform the user that it requires its attention. Does that not happen in your scenario?

No - it seems that someone at Embarcadero is not following the rules.

 

Does it flash when you repeat the described scenario?

 

This is a good example of where stubborn adherence to the rules leads to disadvantages in a smooth workflow. It would be possible to define an exception option in the options.

Share this post


Link to post

What drives me nuts, is the UACs that flashes the icon but doesn't bring the window to front.

There are Windows settings that can affect the bring to front behaviour.

Also, Windows drivers and layout management tools can affect the behaviour.

 

 

  • Like 1

Share this post


Link to post

I don't think there is a good solution (some hacks surely). But I think the choose of Microsoft is a good solution.

 

If are writing something in your TextWriter I don't think you liked that another application start in foreground (and maybe you write on it causing disaster).

 

When I use an application I really don't desire that another application popup in front ....

Share this post


Link to post
2 hours ago, PeterBelow said:

Since several Windows versions an application running in background (= not having the input focus) cannot simply push itself into the foreground anymore because it thinks itself soo much more important than what the user may currently be working with. Instead it flashes its taskbar button to inform the user that it requires its attention.

Hm, in that case the IDE should not be allowed to push itself into the foreground when it hits a breakpoint or catches an exception while debugging a program, when a different program (not the one being debugged) is the foreground window?

Share this post


Link to post

Works for me side by side...   Notice how grouping shows a Instance paired with explorer it was paired with Help.  I like the Startup layout and set the message and callstack views that popout in debug view.  My only complaint is D12 icon same as D11 icon?     

Multiwindow.png

Share this post


Link to post

When you DOUBLE-CLICK a .DPR file it means you really want to load that project in the IDE and work with that project. So, it would be sensible to bring the IDE window to the foreground.

 

Tell me a case where this would not be the case.

Share this post


Link to post
3 hours ago, dummzeuch said:

Hm, in that case the IDE should not be allowed to push itself into the foreground when it hits a breakpoint or catches an exception while debugging a program, when a different program (not the one being debugged) is the foreground window?

It makes better sense when you've read the documentation...

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow

Quote

The system restricts which processes can set the foreground window. A process can set the foreground window by calling SetForegroundWindow only if:

  • All of the following conditions are true:
  • Additionally, at least one of the following conditions is true:
    • The calling process is the foreground process.
    • The calling process was started by the foreground process.
    • There is currently no foreground window, and thus no foreground process.
    • The calling process received the last input event.
    • Either the foreground process or the calling process is being debugged.

It is possible for a process to be denied the right to set the foreground window even if it meets these conditions.

 

And as is usually the case with things like this, Raymond Chen has words:
https://devblogs.microsoft.com/oldnewthing/20090220-00/?p=19083

  • Thanks 1

Share this post


Link to post
On 11/13/2023 at 12:58 PM, PeterPanettone said:

One thing that has been annoying me for a long time: If you double-click a .DPR file in the File Explorer, it is loaded in the IDE, but the IDE is not brought to the foreground!

 

Can anyone confirm this - and is there a way to fix this problem?

This bothered me for ages and never could figure out when it opens in the background and when it opens "correctly".

What is even more strange I forgot about this behavior when I wrote my BDSLauncher... anyway, now it will attempt to bring the selected instance to the foreground after the file has been opened.

 

Thank you for reminding!

Share this post


Link to post

Delphi 12 is better behaved on the taskbar than previous versions. No extra entries on the task bar for the running IDE - just one taskbar icon for both. Can now use Windows key + number key to both launch or switch to it. Even works to cycle between multiple running copies of the same Delphi 12.   (Win+# are shortcuts for the first 10 application icons on the taskbar). 

 

 

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

×