merijnb 4 Posted March 3, 2021 (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 March 3, 2021 by merijnb Share this post Link to post
Dinar 22 Posted March 3, 2021 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 1 Share this post Link to post
dummzeuch 1515 Posted March 3, 2021 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. 1 Share this post Link to post
Dinar 22 Posted March 4, 2021 17 hours ago, Dinar said: I have reproduced this error https://drive.google.com/file/d/1_t70jgff-gHNLppy6WzqkXV5KJU7xL_g/view?usp=sharing Share this post Link to post
dummzeuch 1515 Posted March 4, 2021 4 hours ago, Dinar said: https://drive.google.com/file/d/1_t70jgff-gHNLppy6WzqkXV5KJU7xL_g/view?usp=sharing Thanks. I understood what the bug report said. I just can't reproduce it on my computer. That doesn't mean that I will ignore it. @merijnbs workaround, while it probably works, is not really one I would like to implement. 1 Share this post Link to post
Achim Kalwa 61 Posted March 5, 2021 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
arnop 0 Posted April 27, 2021 I have the same problem. Is there already a fixed GExperts version? Share this post Link to post
dummzeuch 1515 Posted April 28, 2021 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
eivindbakkestuen 47 Posted May 17, 2021 Can confirm it happens every time I use the File Open expert. I use this all the time... Share this post Link to post
chkaufmann 17 Posted May 18, 2021 I just started to work with 10.4.2 (10.3. before) and have the same problem. Share this post Link to post
chkaufmann 17 Posted May 18, 2021 And I can confirm, that this fix works fine for me. Share this post Link to post
dummzeuch 1515 Posted February 27, 2022 patch (from @Achim Kalwa) applied in revision #3811 Share this post Link to post
Attila Kovacs 631 Posted January 21 (edited) You just have to defer the call to "(BorlandIDEServices as IOTAActionServices).OpenFile();", it should be called when the expert window is already closed / the editor has the focus or show the expert window non-modal. Edited January 21 by Attila Kovacs Share this post Link to post