Marus Gradinaru
Marus Gradinaru

Reputation: 3022

Stop scaling a TGraphicControl component

This is my component constructor:

constructor TDiskMap.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
 FCellSize:= 13; FCellsH:= 10; FCellsV:= 10;
 Width:= (FCellsH * FCellSize) + 1;
 Height:= (FCellsV * FCellSize) + 1;
end;

When I run the application, the size of the control is not the one that I set in the constructor, because it is scaled after that. I want to take care myself of scaling and disable this autos-scaling, but TGraphicControl has no Scaled property. I tried to hook WM_SIZW, WM_MINMAXINFO, use Constrains... but no effect. Any ideas ? I want that no one could automatically resize the control, except me. And I mean at the pixel level... regardless of dpi.

Upvotes: 0

Views: 204

Answers (1)

Uwe Raabe
Uwe Raabe

Reputation: 47694

To react on scaling you need to override ChangeScale - to be precise, the three parameter overload of it.

If you don't want the default scaling behavior of the control you should avoid calling inherited in your derived method and handle all necessary calculations by yourself.

Note that this all is only valid when the application is dpi aware in the first place.

Upvotes: 1

Related Questions