formi
asked on
TDbCtrlGrid: how to draw a transparent image?
Hi,
I've a TDBGrid-component and want to draw images on it depending from an integer-value in the database. It'works well, but I can't make the images transparent. There are simple images, I put the images-background to color clBtnFace and draw i.e a green rectangle. On the CtrlGrid the background of the image is always white. I tried to set the "TransparentColor" but without success. The images are 24Bit. Her's my code:
procedure TForm1.DBCtrlGrid1PaintPan el(DBCtrlG rid: TDBCtrlGrid;
Index: Integer);
var
bitmap : TBitmap;
fixRect : TRect;
vTyp : integer;
begin
vTyp := DBCtrlGrid.DataSource.Data Set.FieldB yName('Typ ').AsInteg er;
if vTyp < ImageList1.Count then
begin
bitmap := TBitmap.Create;
try
ImageList1.GetBitmap(vTyp, bitmap);
fixRect.Top := 0;
fixRect.Bottom := fixRect.Top+32;
fixRect.Left := E_Typ.Left+ E_Typ.Width + 3;
fixRect.Right := fixRect.Left+32;
DBCtrlGrid.Canvas.StretchD raw(fixRec t,bitmap);
finally
FreeAndNil(bitmap);
end;
end;
end;
Thanks for your help, Peter
I've a TDBGrid-component and want to draw images on it depending from an integer-value in the database. It'works well, but I can't make the images transparent. There are simple images, I put the images-background to color clBtnFace and draw i.e a green rectangle. On the CtrlGrid the background of the image is always white. I tried to set the "TransparentColor" but without success. The images are 24Bit. Her's my code:
procedure TForm1.DBCtrlGrid1PaintPan
Index: Integer);
var
bitmap : TBitmap;
fixRect : TRect;
vTyp : integer;
begin
vTyp := DBCtrlGrid.DataSource.Data
if vTyp < ImageList1.Count then
begin
bitmap := TBitmap.Create;
try
ImageList1.GetBitmap(vTyp,
fixRect.Top := 0;
fixRect.Bottom := fixRect.Top+32;
fixRect.Left := E_Typ.Left+ E_Typ.Width + 3;
fixRect.Right := fixRect.Left+32;
DBCtrlGrid.Canvas.StretchD
finally
FreeAndNil(bitmap);
end;
end;
end;
Thanks for your help, Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, it works! Great and thanks a lot! (I'm new in experts-exchange and so I didn't saw the button to accept the solution and to send comments to you, so I added a small comment). Peter
Hi formi,
Give it a show with icons.
TICon.Create etc...
Alternative solution is to use TMS components.
http://www.tmssoftware.com/site/gridpack.asp
They have very good components (but expensive).
Another solution is to try with Bergsoft
http://www.bergsoft.net/
Overview : http://www.bergsoft.net/component/next-dbgrid/overview.htm
you can download a demo to see for yourself...
Hope this helps :)
Give it a show with icons.
TICon.Create etc...
Alternative solution is to use TMS components.
http://www.tmssoftware.com/site/gridpack.asp
They have very good components (but expensive).
Another solution is to try with Bergsoft
http://www.bergsoft.net/
Overview : http://www.bergsoft.net/component/next-dbgrid/overview.htm
you can download a demo to see for yourself...
Hope this helps :)
ASKER