打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Lazarus的Grid控件用着很不爽,今天跟踪到底!

Lazarus的Grid控件用着很不爽,今天跟踪到底!

(2011-03-29 21:54:11)

Grid:

TStringGrid = class(TCustomStringGrid

TCustomStringGrid =class(TCustomDrawGrid 

TCustomDrawGrid=class(TCustomGrid)

TCustomGrid=class(TCustomControl)

 

从StringGrid开始追踪,DrawCell到底怎么画出来的:

procedure TCustomStringGrid.DrawCell(aCol, aRow: Integer; aRect:TRect;
  aState: TGridDrawState);
begin
  inherited DrawCell(aCol, aRow, aRect,aState);

procedureTCustomDrawGrid.DrawCell(aCol,aRow: Integer; aRect: TRect;
  aState:TGridDrawState);
var
  OldDefaultDrawing: boolean;
begin
  if Assigned(OnDrawCell) and not(CsDesigning inComponentState) then begin
   PrepareCanvas(aCol, aRow, aState);
    ifDefaultDrawing then
     Canvas.FillRect(aRect);

//从这里看以看出,不管DefaultDrawing是否为真,ONCraw事件都会执行
   OnDrawCell(Self,aCol,aRow,aRect,aState)
  end else begin

    //如果在设计阶段或者没有设置DrawCell过程,则使用默认的方法。
   OldDefaultDrawing:=FDefaultDrawing;
   FDefaultDrawing:=True;
    try
     PrepareCanvas(aCol, aRow, aState);
   finally
     FDefaultDrawing:=OldDefaultDrawing;
    end;
   DefaultDrawCell(aCol,aRow,aRect,aState);

procedureTCustomDrawGrid.DefaultDrawCell(aCol, aRow: Integer; var aRect:TRect;
  aState: TGridDrawState);
begin
  if goColSpanning in Options thenCalcCellExtent(acol, arow, aRect);

 Canvas.FillRect(aRect);

  ifCellNeedsCheckboxBitmaps(aCol,aRow) then
   DrawCellCheckboxBitmaps(aCol,aRow,aRect);

  ifFTitleStyle<>tsNative then
   DrawColumnText(aCol,aRow,aRect,aState);

  if (goFixedRowNumberingin Options) and (FixedCols >= 1) and (aCol = 0)then
   DrawCellAutonumbering(aCol, aRow, aRect, IntToStr(aRow));
end;                                                      


  end;
  DrawCellGrid(aCol,aRow,aRect,aState);
  if FTitleStyle=tsNative then
   DrawColumnText(aCol,aRow,aRect,aState);
end;
         


  if DefaultDrawing then begin
    ifColumns.Enabled and (gdFixed in aState) and
     (aCol>=FixedCols) and (aRow=0) then
     //inherited already did
    else
    if notCellNeedsCheckboxBitmaps(aCol, aRow) then
     DrawCellText(aCol, aRow, aRect, aState, Cells[aCol,aRow]);
  end;
end;               

 

 

 

procedure TCustomGrid.DrawCell(aCol, aRow: Integer; aRect:TRect;
  aState: TGridDrawState);
begin
  //===============aliyagoo===============
 PrepareCanvas(aCol, aRow, aState);
  Canvas.FillRect(aRect);
  DrawCellGrid(aCol,aRow,aRect,aState);
end;

 

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Canvas实现特效
怎么合并stringgrid的单元格,在合并格子里输入文字能居中
delphi中TDBGrid的使用
DrawGrid 做图片显示 代码简单 参考性强 (Delphi7)
Delphi TStringGrid单元格合并
自定义控件
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服