Jump to content
merijnb

Delphi 10.4.2 application switch after using open file expert

Recommended Posts

Posted (edited)

Hi,

I'm using the latest release in Delphi 10.4.2When I'm using the open file expert, after opening a file focus changes to the application which had focus before Delphi was focused. This application is also set in front of Delphi.

I've traced where in code this happens, it seems to be done by the call to ActionServices.OpenFile(FileName) done by GxOtaOpenFile.
I'm not really into ToolsAPI and stuff, but is this still gexperts scope or is this a bug in the IDE?

 

function GxOtaOpenFile(const FileName: string): Boolean;

var
  ActionServices: IOTAActionServices;
begin
  ActionServices := BorlandIDEServices as IOTAActionServices;
  Assert(Assigned(ActionServices));

  Result := ActionServices.OpenFile(FileName);
end;

Can someone confirm they see the same behavior? The same code for me works fine in 10.3.

 

This workaround seems to fix the issue:

 

function GxOtaOpenFile(const FileName: string): Boolean;
var
  ActionServices: IOTAActionServices;
begin
  ActionServices := BorlandIDEServices as IOTAActionServices;
  Assert(Assigned(ActionServices));

  var h := GetForegroundWindow();
  Result := ActionServices.OpenFile(FileName);
  SetForegroundWindow(h)
end;

 

Edited by merijnb

Share this post


Link to post
4 hours ago, merijnb said:

Can someone confirm they see the same behavior? 

I have reproduced this error. GExperts is installed based on revision 3449.

I can't say whether this error was before or not, as I rarely used 'Open file expert' from GExperts

  • Like 1

Share this post


Link to post
5 hours ago, merijnb said:

I'm using the latest release in Delphi 10.4.2When I'm using the open file expert, after opening a file focus changes to the application which had focus before Delphi was focused. This application is also set in front of Delphi.

 

1 hour ago, Dinar said:

I have reproduced this error.

Odd, this doesn't happen on my 10.4.2 test installation (and also not on my 10.4.1 installation).

 

What does happen, is that the editor window loses focus. No idea where it goes. But that's not limited to GExpert's Open File and Delphi 10.4., it also happens without GExperts and e.g. on Delphi 10.2.

  • Like 1

Share this post


Link to post

I can reproduce this, too:

  • start Windows Explorer; if maximized, un-maximize to have a nice window.
  • start RAD Studio/Delphi. if maximized, un-maximize the IDE.
  • use GExperts -> Open File. Select any a pas file

Result:

Windows Explorer gets activated and has the input focus. If the Delphi IDE was maximized, you only see that the focus is lost.

Share this post


Link to post

I have the same problem. Is there already a fixed GExperts version?

Share this post


Link to post
On 4/27/2021 at 8:44 AM, arnop said:

I have the same problem. Is there already a fixed GExperts version?

No, not yet. But you can always get the sources, apply the fix proposed by @merijnb and compile your own DLL.

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
×