Mark Williams 15 Posted June 19 I have a custom component derived from TPanel. There are several other components included including a TToolBar. There was also a TImageList which loaded bitmaps from a resource file to provide the icons for the toolbar. I'm finally getting around to trying to update this to work with TVirtualImageList and transparent PNG files (24 x 24) rather than bitmaps. It works, but is not scaling properly. On higher resolution monitors the toolbuttons are far too small. I suspect my problem is with the scaling of the toolbar rather than the imagelist. But I'm not entirely sure that's correct or what to do about it. The relevant code is below. FImageList := TVirtualImageList.create(self); FImageList.SetSize(TargetSize, TargetSize); FImageList.ImageCollection := FImageCollection; FImageList.DisabledGrayscale := true; FImageList.Height := 24; FImageList.Width := 24; FToolBar := TToolbar.create(self); FToolBar.parent := self; with FToolBar do begin Height := 36; ButtonWidth := 35; ButtonHeight := 35; align := alTop; ShowHint := true; AutoSize := true; Wrapable := true; end; Share this post Link to post
Remy Lebeau 1604 Posted June 19 (edited) The higher the resolution is, the smaller a 24x24 image is going to look. You need multiple images of different sizes, and then choose the appropriate size for a given resolution. Are you doing that? The whole point of TImageCollection is to provide images of different sizes/resolutions, and then TVirtualImageList presents those images at a given size/resolution. Where are you making adjustments based on the current resolution? Edited June 19 by Remy Lebeau Share this post Link to post
Uwe Raabe 2157 Posted June 19 2 hours ago, Remy Lebeau said: The whole point of TImageCollection is to provide images of different sizes/resolutions, and then TVirtualImageList presents those images at a given size/resolution. It also scales the image if the requested size is not present. Share this post Link to post
dwrbudr 10 Posted June 20 I think TVirtualImageList is automatically scaled when DPI changes only when TVirtualImageList is placed on a TForm/TFrame (look for SendChangeScaleMessage in the VCL code). So you'll have to override the panel ChangeScale method and set the image list size. 1 Share this post Link to post
Mark Williams 15 Posted 6 hours ago On 6/20/2025 at 4:11 AM, dwrbudr said: I think TVirtualImageList is automatically scaled when DPI changes only when TVirtualImageList is placed on a TForm/TFrame (look for SendChangeScaleMessage in the VCL code). So you'll have to override the panel ChangeScale method and set the image list size. Taken some time for me to resolve the issue. Managed to override the ChangeScale event, but still couldn't get it to work quite right. However, resolved the issue in the end by changing the component container from TPanel to TFrame. I have other components that use image resources for which the fix won't be that simple. But have dug around and discovered the TCustomForm's onBeforeMonitorDPIChanged and onAfterMonitorDPIChanged events and TWinControl's ScaleForPPI procedure. Suspect these in combination will allow me to do what's needed. I'll post back with the results when I get to it. Share this post Link to post