Mega Code Archive

 
Categories / Delphi / VCL
 

Stringgrid içerisinde bmp

Codec By GeNiUS ! genius@turkiye.com bmpinsgrd.Pas dosyası; unit bmpinsgrd; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,Grids; type TForm1 = class(TForm) StringGrid1: TStringGrid; procedure StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private Bmp : TBitmap; public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} {$R BMPS.RES} procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState); var SRect,DRect : TRect; begin (Sender as TStringGrid).Canvas.FillRect(Rect); if (Sender as TStringGrid).Cells[Row,Col] = '@' then begin SRect := Classes.Rect(0,0,Bmp.Width,Bmp.Height); DRect.Left := Rect.Left+3; DRect.Top := Rect.Top+(Rect.Bottom-Rect.Top-Bmp.Height) div 2; DRect.Right := DRect.Left+SRect.Right+1; DRect.Bottom := DRect.Top+SRect.Bottom+1; (Sender as TStringGrid).Canvas.BrushCopy( DRect,Bmp,SRect,clOlive); end; end; procedure TForm1.FormCreate(Sender: TObject); begin Bmp := TBitmap.Create; Bmp.LoadFromResourceName(HInstance,'BMP'); StringGrid1.Cells[1,1] := '@'; StringGrid1.Cells[3,1] := '@'; end; procedure TForm1.FormDestroy(Sender: TObject); begin Bmp.Free; end; end. bmpinsgrd.DFM dosyası; object Form1: TForm1 Left = 200 Top = 108 Width = 310 Height = 258 Caption = 'Form1' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OnCreate = FormCreate OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 object StringGrid1: TStringGrid Left = 8 Top = 8 Width = 289 Height = 217 TabOrder = 0 OnDrawCell = StringGrid1DrawCell ColWidths = ( 64 70 52 47 40) RowHeights = ( 24 79 24 66 12) end end.