delphi - How do I make my GUI behave well when Windows font scaling is greater than 100% -


when choosing large font sizes in windows control panel (like 125%, or 150%) there problems in vcl application, every time has been set pixelwise.

take tstatusbar.panel. have set width contains 1 label, big fonts label "overflows". same problem other components.

some new laptops dell ship 125% default setting, while in past problem quite rare important.

what can done overcome problem?

note: please see other answers contain valuable techniques. answer here provides caveats , cautions against assuming dpi-awareness easy.

i avoid dpi-aware scaling tform.scaled = true. dpi awareness important me when becomes important customers call me , willing pay it. technical reason behind point of view dpi-awareness or not, opening window world of hurt. many standard , third party vcl controls not work in high dpi. notable exception vcl parts wrap windows common controls work remarkably @ high dpi. huge number of third party , built-in delphi vcl custom controls not work well, or @ all, @ high dpi. if plan turn on tform.scaled sure test @ 96, 125, , 150 dpi every single form in project, , every single third party , built in control use.

delphi written in delphi. has high dpi awareness flag turned on, forms, although in delphi xe2, ide authors decided not turn high dpi awareness manifest flag on. note in delphi xe4 , later, high dpi awareness flag turned on, , ide looks good.

i suggest not use tform.scaled=true (which default in delphi unless you've modified it, of forms have scaled=true) high dpi aware flags (as shown in david's answers) vcl applications built using built-in delphi form designer.

i have tried in past make minimal sample of kind of breakage can expect see when tform.scaled true, , when delphi form scaling has glitch. these glitches not , triggered dpi value other 96. have been unable determine complete list of other things, includes windows xp font size changes. since of these glitches appear in own applications, in complex situations, have decided show evidence can verify yourselves.

delphi xe looks when set dpi scaling "fonts @ 200%" in windows 7, , delphi xe2 broken on windows 7 , 8, these glitches appear fixed of delphi xe4:

enter image description here

enter image description here

these standard vcl controls misbehaving @ high dpi. note things have not been scaled @ all, delphi ide developers have decided ignore dpi awareness, turning off dpi virtualization. such interesting choice.

turn off dpi virtualization if want new additional source of pain, , difficult choices. suggest leave alone. note windows common controls seem work fine. note delphi data-explorer control c# winforms wrapper around standard windows tree common control. that's pure microsoft glitch, , fixing might either require embarcadero rewrite pure native .net tree control data explorer, or write dpi-check-and-modify-properties code change item heights in control. not microsoft winforms can handle high dpi cleanly, automatically , without custom kludge code.

update: interesting factoid: while delphi ide appears not "virtualized", not using manifest content shown david achieve "non-dpi-virtualization". perhaps using api function @ runtime.

update 2: in response how support 100%/125% dpi, come two-phase plan. phase 1 inventory code custom controls need fixed high dpi, , make plan fix them or phase them out. phase 2 take areas of code designed forms without layout management , change them on forms use kind of layout management dpi or font height changes can work without clipping. suspect "inter-control" layout work far more complex in applications "intra-control" work.

update: in 2016, latest delphi 10.1 berlin working on 150 dpi workstation.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -