Is there a way to disable icon scaling in TTreeView - c++builder

I have assigned a 16x16 icons TImageList to a TTreeView object.
Same ImageList is also assigned to a TListView.
When I change the OS dpi setting to display everything at 150% (for instance), the text scales nicely, but so do the icons in the TreeView.
In the ListView the icons stay 16x16 however (same as a few other components).
To keep things uniform (until I implement more icons with different dimensions) is there a way to disable icon scaling in the TreeView ?
TreeView on the left (notice the icons stretched), ListView on the right (icons crisp):

Related

How can I find the correct size of tray bar icons? [duplicate]

I noticed that my app sends icons to the Windows tray with a size of 16x16 pixels--and my Vista PC I've got a doublewide taskbar that appears to show icons at 18x18. The resizing artifacts on my app's icon look awful. How can I ask Windows what size the icons should be?
Edit
I'm generating the icon dynamically, with a pixel font text overlay. It seems wasteful to generate a bunch of icon sizes dynamically, so it would be nice to avoid building an icon with all the "possible" sizes (not that I'm even sure what those are).
GetSystemMetrics(SM_CXSMICON) returns 16--the incorrect value.
GetThemeBackgroundContentRect didn't help, either.
Create your icons in multiple formats, and let Windows select the one it wants.
Here's the Wikipedia article on the .ico format.
If you really need to know, GetSystemMetrics with a parameter of SM_CXICON or SM_CYICON will tell you the width and height that Windows wants to load.
Mark's core answer is the right one: Create your icons in multiple formats and let Windows choose the right one. Don't forget to do 32x32 and 64x64 icons for HighDPI scenarios.
But SM_CXICON/SM_CYICON won't necessarily return the size that will be used in the taskbar. The taskbar chooses the right icon size for it's size (this is much more important in Window 7).
Just provide appropriately sized icons and you should be ok.
Your best bet may be GetThemeBackgroundContentRect passing TBN_BACKGROUND as iPartId for the tray notify background.
GetThemeBackgroundContentRect should return the size defined by the current theme that may be used for drawing without overlapping the borders of the parent element. If I'm reading this correctly, that would be the largest sized notification icon permissible and presumably the size that is being used.
Testing with multiple DPI settings is probably the easiest way to tell if this is returning the correct value.
Per the NOTIFYICONDATA documentation:
If only a 16x16 pixel icon is provided, it is scaled to a larger size in a system set to a high dpi value. This can lead to an unattractive result. It is recommended that you provide both a 16x16 pixel icon and a 32x32 icon in your resource file. Use LoadIconMetric to ensure that the correct icon is loaded and scaled appropriately. See Remarks for a code example.
...
...
// Load the icon for high DPI.
LoadIconMetric(hInst, MAKEINTRESOURCE(IDI_SMALL), LIM_SMALL, &(nid.hIcon));
...
So, creating icons dynamically really isn't the best option. You should provide multiple icons of different sizes statically in your program resources and let Windows choose the best one it wants.

How to apply Anti Aliasing in TImage component with PNG image in real time on Delphi?

I've created an application to display a transparent logo on the screen.
The purpose of this program is to display a logo during multimedia presentations on big screens.
The structure I used in this app is the same as a splash screen.
The difference is that I can switch between transparency mode and form mode by double-clicking the image so that I can resize the logo.
Here is an example of an execution.
The problem, as the image is in a Timage component, it appears with serrated.
Is it possible to apply anti aliasing on the Timage component while maintaining image quality when resizing?

Delphi : differant image sizes in listview

is it possible to add differant image sizes in the same listview
for example
adding item with 32pxl icon and 24pxl subitems
thanks in advance
An image list control is constrained such that all images have the same dimensions. I'm assuming that you are using the vsReport view mode, which means that your images will come from the image list attached to the SmallImages property. And so they must all be the same size.
The constraints are not imposed by Delphi. They are a straight reflection of the underlying Windows control. Windows image lists are implemented in a way that means all images are the same size. They are implemented as a rectangular bitmap that contains all images one after the other. And the various images properties of Delphi's list view control simply wrap the common control functionality – see LVM_SETIMAGELIST.
You could place your 24px images into 32px images with a transparent area to increase the size from 24px to 32px. If that doesn't do what you need, then you'll need to paint the images yourself.

Delphi TImageList PNG alpha renders too dark

I have PNG icons for my Delphi XE3 application toolbar that, when added to a TActionToolbar via a TImageList, the alpha channel renders darker than it should, causing the icons to look bad. I think the issue has to do with the TImageList and not something specifically with the TActionToolbar.
Photoshop mockup:
Actual look after importing to TActionToolbar (alpha is darker blue for the folder fill):
Here are my Delphi Object Inspector settings for the TImageList (no, the issue is not the BlendColor property):
Is there a way to get Delphi/Windows/whoever the culprit is to render the alpha channel properly? An option is to make the icons all bitmaps, but I'd rather not go through the headache of editing bitmaps with a transparent color because, well, I'd rather not revert to the days of the dinosaurs... TIA.
The best way I found to deal with this is to paint the background color of your Delphi toolbar (or whatever UI element) underneath every pixel that contains transparency in Photoshop before saving the PNG image. This way, the toolbar icons are totally opaque except for the 100% transparent pixels, so there is no alpha blending that takes place--and hence no ugliness.
Use RRUZ's code here to make the disabled toolbar icons look better.

Image as a background of a form in Delphi

I'm using Delphi 2006. I have a few PNG images with transparencies and I have to create a GUI using them (top bar, left panel...). The images have different aligns properties. One of the images is the background of the form. The problem here is that I can't align it as alClient because it only occupies the rectangular zone that the other images have left, showing the naked canvas in their transparent zones. What I need is that the background image is put behind all the other images and taking all the canvas size.
Is there anyway to do this? I know I can do this writting some logic in the OnResize event of the form but I was just curious if I was missing something.
Thanks.
Put a TImage on the form and align it with "alClient". Then put an "alClient" aligned Panel on the form. The TPanel is transparent when themes are enabled and "ParentBackground" property is set. Then put the images on the panel and align them at will. If when themes are not enabled is important, you can use a "TJvPanel" which is part of the JVCL library. A search on google also seems to reveal some code for transparent panels.
The above will not help transparency with the "png"s though. AFAIK png support (transparency) is added with D2009 and I don't know if this support includes TImage.
edit: Actually it appears that I owe the very capability to load png images to TImage to the JVCL library itself, and it seems to support transparent "png"s with TImage just fine.

Resources