i would like to use an image from a TPictureContainer in the GetNodeIcon Event of the TAdvTreeView Component. I havent been working on this code a while but i remember that worked.
The types do not match and i cannot find a solution at the moment, but i think there is a simple one but i cannot figure it out.
Hopefully someone can help
Andy
procedure TfrmWebsiteBooster.tvSearchEngineListGetNodeIcon(Sender: TObject;
ANode: TAdvTreeViewVirtualNode; AColumn: Integer; ALarge: Boolean;
var AIcon: TAdvBitmap);
begin
if AColumn = 0 then
if ANode.Node.DataObject <> nil then
if ANode.Node.DataObject.ClassName = 'TSearchEngineProviderListItem' then
begin
// TSearchEngineProviderListItem
if TSearchEngineProviderListItem(ANode.Node.DataObject).ItemIconIndex <> -1 then
if TSearchEngineProviderListItem(ANode.Node.DataObject).ItemIconIndex <= SearchEngineListPictureContainer.Items.Count - 1 then
if Assigned(tvSearchEngineList.PictureContainer) then
AIcon := SearchEngineListPictureContainer.Items.Items[TSearchEngineProviderListItem(ANode.Node.DataObject).ItemIconIndex].Picture;
I tried that but there is no icon displayed ... i checked that the PictureContainer is set and the images are in the Container but it seems that the Image/Icon is not used and will not be displayed
That would indicate retrieval of the picture from the PictureContainer isn't working correct.
Can you access the picture (and its width/height) correct outside this TAdvTreeView event handler?
This is puzzling that from the event you cannot read out width & height properly but from another place in your code you can?
Can this be isolated and a sample source project sent with which we can reproduce this here?
Hi, thank you for the sample. The test is showing the correct image sizes, however for dynamic image sizes, TAdvTreeView is expecting a TAdvBitmap (TPicture), whereas TPictureContainer is returning a TGraphic, not a TPicture. Casting a TGraphic to a TPicture or TAdvBitmap does not work. Instead, you'll have to create an internal list to handle the data separately. The list is filled dynamically based on the name of the image. If the image is included in the list, it will not be added again. please see the modified sample. TestProject.zip (280.7 KB)
Also, please note that you can attach a sample to your post.