2012年3月3日 星期六

MyDac 5.x 修正ftMemo為空時,變成Null

最近準備升級Mysql 4.x -> 5.5
不小發現元件的一個bug,在Memo型態空值時,變會成null
造成5.5 update會跳出 can not be null
簡單的修正方式如下

DBAccess.pas
3375 行
function TDAParam.GetIsNull: boolean;
begin
  if IsBlobDataType then begin
  if DataType in [ftMemo, ftWideMemo] then Result := false
  else Result := TBlob(FParamObject).Size = 0;//原code是只要size為0就是null
  end else
   Result := inherited IsNull;
end;

2012年2月9日 星期四

Delphi 元件設計注意事項

原本是要繼承TPopupMenu的元件,
功能是會產生Grid常用的一些功能
(如:匯出)
第一步當然是在Create時產生需要的TMenuItem

constructor TSmfCxGridPopupMenu.Create(AOwner: TComponent);
begin
inherited;
_CreateMenuItem(); //產生menuitem
end;

結果執行時間竟然會發現menuitem會重覆出現兩次,
百思不得其解。

經過無數Debug發現,原在設計時期,拉元件到Form時會呼叫一次Create
然後Delphi就很熱心的把Create之後的狀態存在DFM

結果就造成執行時,元件Create後,又會載入DFM的狀態
形成MenuItem重覆

解決方法就是設計時期不呼叫CreateMenuItem();

constructor TSmfCxGridPopupMenu.Create(AOwner: TComponent);
begin
inherited;
// 確定在 Run Time 時才有作用,不然會重覆
if not (csDesigning in ComponentState) then _CreateMenuItem();
end;

DevExpress 6.x 新版 Drag a column header here to group by that column 中文化

稍為追了一下code
新版修改變簡單了
打開 cxGridStrs.pas
裡面就是串字對應的文字
修改

scxGridGroupByBoxCaption = '《托曳欄位至此可群組化》';//'Drag a column header here to group by that column';

即可。

其它中文化方式都差不多