Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- var
- gr_RezCli: TIB_Grid;
- gr_RezCli.OnDrawCell := gr_RezCliDrawCell;
- }
- // draw icon in cell if field REZ_MEMO is not empty
- procedure TW_Rez.gr_RezCliDrawCell( Sender: TObject; ACol, ARow: Integer;
- Rect: TRect; State: TGridDrawState );
- var
- sFieldName : String;
- bmp : TBitmap;
- iLeftMargin: Integer;
- iTopMargin : Integer;
- DrawRect : TRect;
- begin
- if (gdFixed in State) or
- not Assigned(gr_RezCli) or
- not Assigned(gr_RezCli.GridFields[ACol-1]) or
- not Assigned(W_DM_Rez) or
- not Assigned(W_DM_Rez.D_Rez_Cli) or
- not Assigned(W_DM_Rez.Q_Rez_Cli) or
- //not W_DM_Rez.Q_Rez_Cli.Prepared or
- not W_DM_Rez.Q_Rez_Cli.Active or
- W_DM_Rez.Q_Rez_Cli.FieldByName('ID_REZEPT').IsNull or
- (W_DM_Rez.Q_Rez_Cli.RecordCount < 1) then
- begin
- exit;
- end;
- try
- W_DM_Rez.Q_Rez_Cli.BufferRowNum := gr_RezCli.DataRow[ARow];
- sFieldName := UpperCase( gr_RezCli.GridFields[ACol-1].FieldName );
- if (sFieldName = 'REZ_MEMO') and
- not W_DM_Rez.Q_Rez_Cli.BufferFieldByName('REZ_MEMO').IsNull then
- begin
- // inflate rect by line width
- Rect.Left := Rect.Left + 1;
- Rect.Right := Rect.Right - 1;
- Rect.Top := Rect.Top + 1;
- Rect.Bottom := Rect.Bottom - 1;
- // fill background
- gr_RezCli.Canvas.FillRect( Rect );
- // icon
- bmp := TBitmap.Create;
- try
- // load bitmap from resource
- Bingo_LoadBitmapByIdent( imgDateInfo, bmp );
- // center icon
- iLeftMargin := ((Rect.Right-Rect.Left) - bmp.Width) div 2;
- iTopMargin := ((Rect.Bottom-Rect.Top) - bmp.Height) div 2;
- DrawRect := Bounds( Rect.Left+iLeftMargin, Rect.Top+iTopMargin, bmp.Width, bmp.Height );
- // draw icon
- gr_RezCli.Canvas.BrushCopy( DrawRect, bmp, Bounds(0, 0, bmp.Width, bmp.Height),
- bmp.TransparentColor );
- finally
- bmp.Free;
- end;
- end;
- except
- on E: Exception do begin
- // log stuff
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement