SaLz
asked on
Icon in ListBox problem
For one of my other questions, to put an icon in a ListBox, Radikal did this:
https://www.experts-exchange.com/questions/21524774/adding-an-icon-to-the-listbox.html
But when you select an item, the icon loses it's transparent parts, how could i have it so the icon keeps it's transparent parts ?
Thank you,
Sal
https://www.experts-exchange.com/questions/21524774/adding-an-icon-to-the-listbox.html
But when you select an item, the icon loses it's transparent parts, how could i have it so the icon keeps it's transparent parts ?
Thank you,
Sal
Had a quick look, might need to draw a background, let me check and come back to you
I dont get any issues with images losing quality.
Maybe it is a problem with the images you are using?
Maybe it is a problem with the images you are using?
Try this instead
procedure TForm1.ListBox1DrawItem(Co ntrol: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TListBox) do
begin
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+I mageList1. Height+2,R ect.Top,It ems[Index] );
ImageList1.Draw(Canvas,Rec t.Left,Rec t.Top,strt oint(Items [Index]));
end;
end;
procedure TForm1.ListBox1DrawItem(Co
Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TListBox) do
begin
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+I
ImageList1.Draw(Canvas,Rec
end;
end;
Hi!
Ejem...
procedure TForm1.ListBox1DrawItem(Co ntrol: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TListBox) do
begin
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+I mageList1. Height+2,R ect.Top,It ems[Index] );
ImageList1.Draw(Canvas,Rec t.Left,Rec t.Top,Inde x);
end;
end;
Ejem...
procedure TForm1.ListBox1DrawItem(Co
Rect: TRect; State: TOwnerDrawState);
begin
with (Control as TListBox) do
begin
Canvas.FillRect(Rect);
Canvas.TextOut(Rect.Left+I
ImageList1.Draw(Canvas,Rec
end;
end;
ASKER
Thank you guys, but it doesnt seem to work, it doesnt show any icon ? :/
Test again, load any icon in the imagelist, Ownerdraw to...
Works perfectly... :)
Works perfectly... :)
ASKER
Nice, forgot about ownerdraw .. ty :)
Btw, is there any way to have two icons next to the text ? I can open this q in new thread :)
Thank you both guys
Btw, is there any way to have two icons next to the text ? I can open this q in new thread :)
Thank you both guys
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you :)