Jump to content
dummzeuch

The state of GExperts Support for Delphi 11

Recommended Posts

There is now a GExperts project in the svn repository, that compiles with Delphi 11 (see .\projects\DelphiXx110Alexandria).

 

If you don't know already, there is a page on my blog telling you how to compile your own DLL.

 

It mostly seems to work too, but there are quite a lot of caveats, most related to the new High DPI awareness of the IDE.

 

The simple workaround, if you value GExperts functionality more than the High DPI awareness: Start Delphi with the "Delphi 11 (DPI unaware)" start menu entry. This also fixes quite a few display quirks I have already found in the new Delphi version.

 

If you do that, you should probably also disable all the experts that you don't need, because I haven't tested many of them on Delphi 11 yet at all and they might have undesired side effects even if not actively used.

 

Unfortunately the trick Uwe Raabe blogged about, for using High DPI unaware forms in High DPI aware applications doesn't seem to work. I tried to change the code for opening the GExperts configuration dialog like this:

procedure ShowGXConfigurationForm;
var
  previousDpiContext: DPI_AWARENESS_CONTEXT;
  frm: TfmConfiguration;
begin
  previousDpiContext := SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
  try
    frm := TfmConfiguration.Create(nil);
  finally
    SetThreadDpiAwarenessContext(previousDpiContext);
  end;
  try
    frm.ShowModal;
  finally
    frm.Free;
  end;
end;

But it changed nothing. The Dialog is still displayed too small to comfortably use on a 4K monitor with scaling set to 150.

 

I'll try to get this sorted. Any help will be appreciated.

  • Thanks 1

Share this post


Link to post

If the form is showed modal you can try to wrap the whole thing:

procedure ShowGXConfigurationForm;
var
  previousDpiContext: DPI_AWARENESS_CONTEXT;
  frm: TfmConfiguration;
begin
  previousDpiContext := SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
  try
    frm := TfmConfiguration.Create(nil);
    try
      frm.ShowModal;
    finally
      frm.Free;
    end;
  finally
    SetThreadDpiAwarenessContext(previousDpiContext);
  end;
end;

I have to say that I didn't test nor use this approach in a DLL, especially not in an IDE plugin. So there might be more intricacies than I am aware of.

  • Thanks 1

Share this post


Link to post
15 minutes ago, Uwe Raabe said:

If the form is showed modal you can try to wrap the whole thing

... from Create, ShowModal to Free.

 

Yes, that did the trick, at least for the configuration dialog. I'll try some others.

 

Thanks a lot!

Share this post


Link to post

Maybe some of the scaling issues could be solved by setting Form.Scaled := True. I've added

procedure TfmBaseForm.Loaded;
begin
  inherited;
  {$IFDEF IDE_IS_HIDPI_AWARE}
  Scaled := True;
  {$ENDIF}
end;

to TfmBaseForm (GX_BaseForm.pas) (to not edit every dfm by hand). But I am not sure if this works on all inherited forms. My first test with the "Goto" experts are looking good:

1975572875_GXScaling.thumb.png.3bc504e850bcdc511c060dffecb37281.png

 

Achim

Share this post


Link to post

Scaled = true seems to work for the Goto dialog, but neither in the Configuration nor the About dialog. But thanks for the pointer. I had totally forgotten about that property.

 

Edit: Your screenshots look different from my dialog. I have got an empty space below the buttons. But that's with 150% scaling configured for that monitor.

 

Edit2: I also get that space with 125% scaling but it's smaller.

Edited by dummzeuch

Share this post


Link to post

I have now adapted several forms to look OK in Delphi 11, using Uwe's "hack" with a wrapper interface so I don't have to repeat too much code, but it's still too much copy and paste for my taste.

 

I have also added Delphi 11 support to some experts that need to know about the new version (e.g. the IfDef editor expert).

 

Given that even quite a few of the IDEs own forms look way too small on a 4K monitor, I think that's quite some progress.

 

It's still not finished and there will be bugs. But I'll call it a day now.

  • Thanks 1

Share this post


Link to post
12 hours ago, Rick Hollerich said:

When I try to compile 3598, I get an undeclared identifier error for "TemporarilyDisableHighDpi".

Try again now, I just committed the missing change.

Share this post


Link to post

All modal dialogs, that do not directly interact with the IDE, have now been changed to look reasonable with high DPI (by disabling high DPI for them for now, but that's better than nothing and takes much less time). One notable exception is the Open File expert which I didn't get to work because it opens a file in the editor before closing the dialog causing the IDE to crash.

 

Also, I still need to find a solution for those windows that can be docked. This means e.g. that the Grep Search dialog looks OK but the Grep Result window is nearly unreadable on high DPI monitors.

Share this post


Link to post
6 minutes ago, dummzeuch said:

I still need to find a solution for those windows that can be docked.

There is none - except making them support High DPI, of course. Only top level windows can have their own DPI awareness context, so docked windows share it with the IDE.

 

8 minutes ago, dummzeuch said:

One notable exception is the Open File expert which I didn't get to work because it opens a file in the editor before closing the dialog causing the IDE to crash.

SetThreadDpiAwarenessContext targets the thread and has the effect that all Winapi calls are done with the given DPI awareness context. I didn't inspect the relevant source code, but you can try to hand the previous context to the dialog and let it temporarily switch back during the file being opened in the editor. Perhaps you can find a place to restore the context somewhere inside the dialog earlier, but I cannot point you to the correct one.

 

The moment when the context can be restored depends on which WinApi calls are executed when. For simple forms it seems to be sufficient to wrap the Create, but that may be different for more complex scenarios.

Share this post


Link to post
33 minutes ago, Uwe Raabe said:

There is none - except making them support High DPI, of course.

docked windows share it with the IDE.

That's what I was expecting, I just need to find out how to do that. I would have preferred that for all forms, but I my time is limited.

 

36 minutes ago, Uwe Raabe said:

Perhaps you can find a place to restore the context somewhere inside the dialog earlier, but I cannot point you to the correct one.

I found a solution for the Uses Clause Manager which also allows opening a unit in the editor. But that solution didn't work for the Open File expert.

Share this post


Link to post
3 minutes ago, dummzeuch said:

I just need to find out how to do that.

Ideally it works out of the box, but that is rarely the case.

 

First the VCL has a new default font Segoe UI 9pt, which is a bit larger than the previous. As the IDE makes also use of this, controls with ParentFont = true may be larger as expected. While labels usually handles that with their AutoSize property, CheckBoxes are more prone to clipping their text.

(Side note: ParentFont = False doesn't work well either in the moment.)

 

Icons are often the main barrier as you should provide different or at least larger sizes. The problem is using virtual ImageLists on the form or frame, where they are scaled properly, instead common image lists in some data module. Well, that's not the actual problem - that is keeping the old way working for the older Delphi versions, wich don't know about TVirtualImageList in the first place. One approach, when few forms are affected, can be stolen studied from the imagelist editor in PngComponents. It is also used in Project Magician and Selective Debugging, but for MMX I implemented a totally different approach, where explaining would go beyond scope here,

 

I will be happy to help if you need some advice.

  • Thanks 1

Share this post


Link to post

Hi Thomas,

Win 11, D11, GE rev 3612.  4k monitor (3840 x 2160 - 150%)

Understanding that it is still a work in progress, this is purely FYI.

D2007 build fails with..

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Borland.Delphi.Targets(113,3): error : D:\GExperts\source\ReplaceComponents\GX_ReplaceCompMapDets.pas(9) Fatal: F1026 File not found: 'System.
Actions.dcu'
    D:\GExperts\source\ReplaceComponents\GX_ReplaceCompMapDets.pas(9) Fatal: F1026 File not found: 'System.Actions.dcu'
Done building target "CoreCompile" in project "GExpertsDelphi2007.dproj" -- FAILED.

Done building project "GExpertsDelphi2007.dproj" -- FAILED.

Build FAILED.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Borland.Delphi.Targets(113,3): error : D:\GExperts\source\ReplaceComponents\GX_ReplaceCompMapDets.pas(9) Fatal: F1026 File not found: 'System.Acti
ons.dcu'
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.61
done building GExpertsDelphi2007.dproj

D10.4.2 Builds and looks/runs fine.

D11 builds with the following warning..

D:\GExperts\externalsource\abbrevia\AbDfEnc.pas(814): Hint warning H2077: Value assigned to 'Deflate' never used [D:\GExperts\Projects\DelphiXx110Alexandria\GExpertsRS110.dproj]
  472479 lines, 2.78 seconds, 2980984 bytes code, 41188 bytes data.
Done Building Project "D:\GExperts\Projects\DelphiXx110Alexandria\GExpertsRS110.dproj" (rebuild target(s)).


Build succeeded.

"D:\GExperts\Projects\DelphiXx110Alexandria\GExpertsRS110.dproj" (rebuild target) (1) ->
(_PasCoreCompile target) ->
  D:\GExperts\externalsource\abbrevia\AbDfEnc.pas(814): Hint warning H2077: Value assigned to 'Deflate' never used [D:\GExperts\Projects\DelphiXx110Alexandria\GExpertsRS110.dproj]

    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.96
done building GExpertsRS110.dproj

Seems to run OK but looks terrible.

image.thumb.png.d66893816f830be98d48f57866d63c62.png

 

Thank you for your commitment to this.

 

Regards,

Ian

Edited by Ian Branch
Added Monitor settings.

Share this post


Link to post
12 hours ago, Ian Branch said:

D2007 build fails with..


error : D:\GExperts\source\ReplaceComponents\GX_ReplaceCompMapDets.pas(9) Fatal: F1026 File not found: 'System.
Actions.dcu'

 

Fixed. I should have done a build for older versions before committing.

12 hours ago, Ian Branch said:

D11 builds with the following warning..


  D:\GExperts\externalsource\abbrevia\AbDfEnc.pas(814): Hint warning H2077: Value assigned to 'Deflate' never used

 

Yes, I'm aware of this, but that's a 3rd party unit.

 

12 hours ago, Ian Branch said:

Seems to run OK but looks terrible.

image.thumb.png.d66893816f830be98d48f57866d63c62.png

 

This is odd. That dialog looks "fine" on my computer on a 31" monitor with 3820x2160 and 150% scaling (also tried 125% scaling), and also on a 24" monitor with 1920x1200 and 100% scaling.

"Fine" meaning everything is readable, though a bit blurry due to Windows GDI scaling, same as in older versions.

Share this post


Link to post

The D11 .dll provided by Dave Nottage did the same thing.  See the other thread.  "r3588 and Alexandria."

 

My monitor is a 27"

I wonder if it is a combination of D11 & Windows 11 thing??

It is fine under D10.4.2 & Win 11.

What are your D11 display/DPI settings?

 

Ian

Share this post


Link to post
8 minutes ago, Ian Branch said:

The D11 .dll provided by Dave Nottage did the same thing.  See the other thread.  "r3588 and Alexandria."

Yes, but that one was probably built without trying to fix any High DPI issues (I can only guess because I don't have the source code it was built from.)

 

9 minutes ago, Ian Branch said:

I wonder if it is a combination of D11 & Windows 11 thing??

Windows 11? Great, yet another variable. I'm using Windows 10.

10 minutes ago, Ian Branch said:

It is fine under D10.4.2 & Win 11.

Yes, that's because Delphi < 11 was not High DPI aware.

11 minutes ago, Ian Branch said:

What are your D11 display/DPI settings?

I'm starting Delphi 11 without the "/highdpi:unaware" switch and have left the User interface -> Form Designer -> High DPI setting at its default "Low DPI (96 PPI) and checked the option "Scale gid size / snap tolerance to design PPI" (no idea if that's the default).

Are there any other settings I should be aware of?

 

(My IDE shows some really odd behaviours regarding DPI. The object inspector starts out fine but switches to nearly unreadable small fonts after a while. Some dialogs are also apparently broken. And it's not GExperts causing this, because I have now uninstalled it to check.)

17 minutes ago, Ian Branch said:

My monitor is a 27" 

Is that your only monitor? Or do you have two of those?

I have got one 31" 4K monitor as secondary display and one 1920x1200 monitor as primary display. I guess that some oddities I observe are due to the IDE being on the secondary monitor. That has also been the case with all of the previous Delphi versions, but none has been so bad as this one.

Share this post


Link to post

I can now reproduce this by using only the 4K monitor. Just what I need: Yet another variable.

Share this post


Link to post
On 9/11/2021 at 5:06 PM, Achim Kalwa said:

Maybe some of the scaling issues could be solved by setting Form.Scaled := True. I've added


procedure TfmBaseForm.Loaded;
begin
  inherited;
  {$IFDEF IDE_IS_HIDPI_AWARE}
  Scaled := True;
  {$ENDIF}
end;

to TfmBaseForm (GX_BaseForm.pas) (to not edit every dfm by hand). But I am not sure if this works on all inherited forms. My first test with the "Goto" experts are looking good:

1975572875_GXScaling.thumb.png.3bc504e850bcdc511c060dffecb37281.png

I just tried this again:

 

It works fine if I only use my 4K monitor. But if I use both (4K and 1920x1200) it looks like this:

goto-both-monitors.png.070cf015043e7ff5dd6e6934305a3996.png

 

So it seems that most of my problems are caused by using two different monitors (or rather using different scaling on them, because it works if I set both to 150%). But wasn't that what per monitor DPI awareness was supposed to solve? 😞

Share this post


Link to post
26 minutes ago, dummzeuch said:

I'm starting Delphi 11 without the "/highdpi:unaware" switch

Where is this set/setting?  I have the 96dpi set as you have.

I have two 4k monitors, set exactly the same.

Share this post


Link to post
1 minute ago, Ian Branch said:

Where is this set/setting?  I have the 96dpi set as you have.

It's passed to bds.exe from the start menu entries suffixed with "(DPI unaware)".

Edited by dummzeuch

Share this post


Link to post
4 minutes ago, Ian Branch said:

the "/highdpi:unaware" switch

That fixed it..

image.thumb.png.2dddae80431f88989f2dd36ea1a99e62.png

image.thumb.png.b5125edfed97457383dec80939cc3efb.png

image.thumb.png.f800f77e9fd334769c09ba39c6125868.png

 

But I view that as a stop-gap measure.  😉

 

Regards,

Ian

Share this post


Link to post

That switch turns off High DPI awareness for the whole IDE. As I wrote in the first post on this topic:

On 9/11/2021 at 12:39 PM, dummzeuch said:

The simple workaround, if you value GExperts functionality more than the High DPI awareness: Start Delphi with the "Delphi 11 (DPI unaware)" start menu entry. This also fixes quite a few display quirks I have already found in the new Delphi version.

Share this post


Link to post

To be honest - after your fixes, it's even worse than it was before under HighDPI. I was using GExperts during beta - it was not beautiful but most dialogs could be used.

 

Now it looks like this:

image.thumb.png.6d677457547460ab20fbf052f16347b9.png

Edited by Stefan Glienke
  • Sad 1

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
×