首先是TControlBar:
OnPaint事件和OnBandPaint的关系是:
procedure TCustomControlBar.Paint;
-->
OnPaint(Self);
-->for I := 0 to FItems.Count - 1 do
-->PaintControlFrame(Canvas, Control, R);
-->DoBandPaint(AControl, Canvas, ARect, Options);
-->
OnBandPaint(Self, Control, Canvas, ARect, Options);
OnPaint事件解发在先,对整个TControlBar。OnBandPaint在后仅一个Band。
当然OnPaint中不能决定它绘什么不绘什么,而OnBandPaint中则可以更改Options决定它能绘什么。
若果windows没有启用Themesp,TControlBar画的那条竖线确实有碍美观,特别是bpoGradient时,不过完全可以参考TCustomControlBar.PaintControlFrame自己画一个。
TCustomControlBar.PaintControlFrame的代码:
- procedureTCustomControlBar.PaintControlFrame(Canvas:TCanvas;AControl:TControl;
- varARect:TRect);
- const
- Offset=3;
- var
- R:TRect;
- ElemDetails:TThemedElementDetails;
- Options:TBandPaintOptions;
- procedureDrawGrabber;
- begin
- withCanvas,Rdo
- begin
- Pen.Color:=clBtnHighlight;
- MoveTo(R.Left+2,R.Top);
- LineTo(R.Left,R.Top);
- LineTo(R.Left,R.Bottom+1);
- Pen.Color:=clBtnShadow;
- MoveTo(R.Right,R.Top);
- LineTo(R.Right,R.Bottom);
- LineTo(R.Left,R.Bottom);
- end;
- end;
- begin
- ifFDrawingStyle=dsGradientthen
- Options:=[bpoGrabber,bpoGradient,bpoRoundRect]
- else
- Options:=[bpoGrabber,bpoFrame];
- DoBandPaint(AControl,Canvas,ARect,Options);
- withCanvasdo
- begin
- ifbpoFrameinOptionsthen
- DrawEdge(Handle,ARect,BDR_RAISEDINNER,BF_RECT);
- ifbpoRoundRectinOptionsthen
- begin
- BeginPath(Handle);
- Polyline([Point(ARect.Left+Integer(CornerEdge),ARect.Top),
- Point(ARect.Right-Integer(CornerEdge),ARect.Top),
- Point(ARect.Right,ARect.Top+Integer(CornerEdge)),
- Point(ARect.Right,ARect.Bottom-Integer(CornerEdge)),
- Point(ARect.Right-Integer(CornerEdge),ARect.Bottom),
- Point(ARect.Left+Integer(CornerEdge),ARect.Bottom),
- Point(ARect.Left,ARect.Bottom-Integer(CornerEdge)),
- Point(ARect.Left,ARect.Top+Integer(CornerEdge)),
- Point(ARect.Left+Integer(CornerEdge),ARect.Top)]);
- EndPath(Handle);
-
- SelectClipPath(Handle,RGN_COPY);
- end;
- ifbpoGradientinOptionsthen
- begin
-
- GradientFillCanvas(Canvas,GetHighlightColor(GradientStartColor),
- GetShadowColor(GradientEndColor),ARect,GradientDirection);
- R:=ARect;
- InflateRect(R,-Pen.Width,-Pen.Width);
-
- GradientFillCanvas(Canvas,GradientStartColor,GradientEndColor,
- R,GradientDirection);
- end;
- ifbpoGrabberinOptionsthen
- begin
- ifThemeServices.ThemesEnabledthen
- begin
- ElemDetails:=ThemeServices.GetElementDetails(trGripper);
- R:=Rect(ARect.Left+2,ARect.Top+2,ARect.Left+5+2,ARect.Bottom-3);
- ThemeServices.DrawElement(Canvas.Handle,ElemDetails,R);
- endelse
- begin
- R:=Rect(ARect.Left+Offset,ARect.Top+2,ARect.Left+Offset+2,
- ARect.Bottom-3);
- DrawGrabber;
- end;
- end;
- end;
- end;
改掉上面的DrawGrabber,爱怎么画就怎么画。当然还是建议在OnBandPaint事件里画,而不是改控件代码。
然后是TDBComboboxEh:
EhLib的控件不错,但总有些毛病,比如将控件连接到一个Boolean类型的字段,在KeyItems里写下false和true,结果呢?下拉列表能出来,选了也能更新到数据库,但控件自己显示的却是空白。翻了翻代码,原来它用KeyItems.IndexOf(FDataLink.Field.Text)来查找(GetDisplayTextForPaintCopy函数里),Boolean类型的Field.Text是False和True(首字母大写),改正后一切正常。
接着是Abstract Error:
将一个界面的控件类型大批量换掉后(直接改dfm文件),运行程序报Abstract Error,查来查去才发现,原来之前为Form指定了ActiveControl,而那个Control已经被转换成TDBText了,晕~~~~~
FastReport:
已经有4.7.3了,不过项目太紧,不敢现在更新控件。
Toad Data Modeler Library:
Case Studio卖了后,取而代之的是Toad Data Modeler Library,看了看资料,变了很多,功能也加强了很多,不敢马上用,项目完了再试。
最后是db4o:
最后的O是Object,面向对象的开源数据库,支持Java和.Net,遵守GPL协议,且免费!!!有兴趣了的Google去!
个人札记,拒绝转载!