delphi代码翻译成bcb,在表格前面加自动行号
在DevExpress VCL Demos代码中,有一段是在表头加序号的代码,我想把他翻译成bcb代码
procedure TfrmGridCellSelection.TableViewCustomDrawIndicatorCell(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
ATextRect: TRect;
AText: String;
ABorders: TcxBorders;
AStyle: TcxStyle;
begin
if AViewInfo is TcxGridIndicatorRowItemViewInfo then
begin
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
AText := IntToStr(AIndicatorViewInfo.GridRecord.Index + 1);
InflateRect(ATextRect, -2, -1);
ABorders := cxBordersAll;
if Sender.LookAndFeelPainter.LookAndFeelStyle = lfsUltraFlat then
ABorders := ABorders - [bTop];
if AIndicatorViewInfo.GridRecord.Selected then
AStyle := styleSelected
else AStyle := styleNormal;
Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds, ATextRect, [], ABorders, cxbsNormal, taCenter, vaCenter,
False, False, AText, AStyle.Font, AStyle.TextColor, AStyle.Color);
ADone := True;
end;
end;
void __fastcall TUMainForm::cxGridDBTableViewCustomDrawIndicatorCell(TcxGridTableView *Sender, TcxCanvas *ACanvas,
TcxCustomGridIndicatorItemViewInfo *AViewInfo, bool &ADone) {
/*
AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
ATextRect: TRect;
AText: String;
ABorders: TcxBorders;
AStyle: TcxStyle;
begin
if AViewInfo is TcxGridIndicatorRowItemViewInfo then
begin
ATextRect := AViewInfo.ContentBounds;
AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
AText := IntToStr(AIndicatorViewInfo.GridRecord.Index + 1);
InflateRect(ATextRect, -2, -1);
ABorders := cxBordersAll;
if Sender.LookAndFeelPainter.LookAndFeelStyle = lfsUltraFlat then
ABorders := ABorders - [bTop];
if AIndicatorViewInfo.GridRecord.Selected then
AStyle := styleSelected
else AStyle := styleNormal;
Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds, ATextRect, [], ABorders, cxbsNormal, taCenter, vaCenter,
False, False, AText, AStyle.Font, AStyle.TextColor, AStyle.Color);
ADone := True;
end;
end;
*/
TcxGridIndicatorRowItemViewInfo *AIndicatorViewInfo;
TRect ATextRect;
String AText;
TcxBorders ABorders;
TcxStyle *AStyle;
ATextRect = AViewInfo->ContentBounds;
AIndicatorViewInfo = (TcxGridIndicatorRowItemViewInfo*)AViewInfo;
AText = IntToStr(AIndicatorViewInfo->GridRecord->Index + 1);
InflateRect(&ATextRect, -2, -1);
ABorders = cxBordersAll;
Sender->LookAndFeelPainter->DrawHeader(ACanvas, AViewInfo->ContentBounds, ATextRect,
[], //这里不知道怎么翻译
ABorders,
cxbsNormal,
taCenter,
vaCenter,
False,
False,
AText,
AStyle->Font,
AStyle->TextColor,
AStyle->Color);
ADone = true;
}
没翻译成功
//DrawHeader方法
virtual void __fastcall DrawHeader(Cxgraphics::TcxCanvas* ACanvas, const Types::TRect &ABounds, const Types::TRect &ATextAreaBounds, TcxNeighbors ANeighbors, Cxgraphics::TcxBorders ABorders, TcxButtonState AState, Classes::TAlignment AAlignmentHorz, Cxclasses::TcxAlignmentVert AAlignmentVert, bool AMultiLine, bool AShowEndEllipsis, const System::UnicodeString AText, Graphics::TFont* AFont, Graphics::TColor ATextColor, Graphics::TColor ABkColor, TcxDrawBackgroundEvent AOnDrawBackground = 0x0, bool AIsLast = false, bool AIsGroup = false); 自动序号 bcb TcxGrid TcxGridDBTableView Indicator
[解决办法]
有时候看懂代码后重新写一遍,要比翻译代码省事
[解决办法]
本帖最后由 ccrun 于 2013-03-18 13:54:40 编辑 定义一个Cxgraphics::TcxBorders对象,然后代入即可,如:
Cxgraphics::TcxBorders x;
Sender->LookAndFeelPainter->DrawHeader(ACanvas, AViewInfo->ContentBounds,
ATextRect, x, ABorders, cxbsNormal, taCenter, vaCenter.....