-1

I've a question about High-DPI application in Delphi. Surfing on the Internet I've found a series of articles published by Žarko Gajić. these articles speaks about create Delphi application ready for High-DPI. The method describes works fine but, the author use it inside every single application; for example speaking about TSpeedButtons.

My question is this: there is a way to implement this kind of behaviour also into components? For example I'm realising a simple component that works like the Embarcadero TSpeedButton but using Transparent PNG images. The images inside the component are loaded at design-time from some PNG images. I've a TObjectDictionary in which I register the buttons states: enabled, disabled and so on.It is declared in this way:

FGlyphs: TObjectDictionary<TGlyphState, TPicture>

In the application that use this component I load PNG images from the files that are 24 x 24 pixel. When I execute the application on a 4K monitor this images become very small. If I apply the Žarko method all works well but in this way every application the use my component need to implement this solution.

How to implement it directly inside the component? I thought to implement it inside the SetGlyph procedure, that is like the following code, but I don't know if this is the right place.

procedure TNCRSpeedButton.SetGlyphs(Index: TGlyphState; Value: TPicture);
begin
  FGlyphs.Items[Index].Assign(Value);
end;

TGlyphState is defined in this way:

TGlyphState = (gtEnabled, gtDisabled, gtDown, gtOver);

Eros

1
  • High-DPI awareness is dependent on each individual application and not on each individual component. You can not have High-DPI aware component if the application doesn't support High-DPI awareness. Nov 1, 2018 at 14:44

1 Answer 1

-1

1) First of all you should enable option Enable High-Dpi in Project Option -> Application -> your target platform -> Manifest file. This option is available since Delphi 10 (Seattle).

2) if in W10 OS you have different Scale, you could calculate and run TWinControl.ScaleBy (available for Forms) for adjust window and all elements on one specific window.

See demo on https://github.com/KohrAhr/DelphiDemoPPI

Demo contain TToolButtons controls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.