研究心得------->Seskin控制項包中SeskinEdit漢字問題的解決辦法

來源:互聯網
上載者:User
漢字|解決|控制項|問題|心得 公司採用Seskin控制項包來開發。卻發現SeskinEdit在使用漢字是有問題。主要是由漢字時游標定位不準。滑鼠選字也選不準。
於是看了其代碼。發現它在計算文本長度時採用的函數TextLength有問題。
其實TCanvas提供了一個TextLength方法,在去文本長度時漢字沒有問題。
所以把這裡替換下來就行了。
替換後的se_controls單元中的TSeCustomEdit的代碼如下
TSeCustomEdit = class(TSeCustomControl)
private
FText: WideString;
FLMouseSelecting: boolean;
FCaretPosition: integer;
FSelStart: integer;
FSelLength: integer;
FFirstVisibleChar: integer;
FPopupMenu: TSeCustomPopupMenu;
FAutoSelect: boolean;
FCharCase: TEditCharCase;
FHideSelection: Boolean;
FMaxLength: Integer;
FReadOnly: Boolean;
FOnChange: TNotifyEvent;
FPasswordChar: WideChar;
FPasswordKind: TPasswordKind;
FTextAlignment: TAlignment;
FActionStack: TEditActionStack;
FPopupMenuDropShadow: boolean;
FPopupMenuShowAnimationTime: integer;
FPopupMenuBlendValue: integer;
FPopupMenuShadowWidth: integer;
FPopupMenuShowAnimation: TSeAnimationRec;
FPopupMenuBlend: boolean;
FContextMenuOptions: TSePopupMenuOptions;
procedure UpdateFirstVisibleChar;
procedure UpdateCaretePosition;
procedure UpdateCarete;

procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMCopy(var Message: TMessage); message WM_COPY;
procedure WMPaste(var Message: TMessage); message WM_PASTE;
procedure WMCut(var Message: TMessage); message WM_CUT;
procedure WMUnDo(var Message: TMessage); message WM_UNDO;
procedure WMContexMenu(var Message: TMessage); message WM_CONTEXTMENU;
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message
WM_LBUTTONDBLCLK;
{ unicode }
procedure WMImeStartComposition(var Message: TMessage); message
WM_IME_STARTCOMPOSITION;
procedure WMImeComposition(var Msg: TMessage); message WM_IME_COMPOSITION;
{ VCL messages }
procedure CMEnabledChanged(var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMTextChanged(var Msg: TMessage); message CM_TEXTCHANGED;

function GetSelText: WideString;
function GetVisibleSelText: WideString;
function GetNextWordBeging(StartPosition: integer): integer;
function GetPrivWordBeging(StartPosition: integer): integer;
function GetSelStart: integer;
function GetSelLength: integer;
function GetText: WideString;
procedure SetText(const Value: WideString);
procedure SetFont(Value: TFont);
procedure SetCaretPosition(const Value: integer);
procedure SetSelLength(const Value: integer);
procedure SetSelStart(const Value: integer);
procedure SetAutoSelect(const Value: boolean);
procedure SetCharCase(const Value: TEditCharCase);
procedure SetHideSelection(const Value: Boolean);
procedure SetMaxLength(const Value: Integer);
procedure SetPasswordChar(const Value: WideChar);
procedure SetCursor(const Value: TCursor);
procedure SetTextAlignment(const Value: TAlignment);
procedure SetPasswordKind(const Value: TPasswordKind);
procedure SetPopupMenuBlendValue(const Value: integer);
procedure SetPopupMenuDropShadow(const Value: boolean);
procedure SetPopupMenuShadowWidth(const Value: integer);
procedure SetPopupMenuShowAnimation(const Value: TSeAnimationRec);
procedure SetPopupMenuShowAnimationTime(const Value: integer);
procedure SetPopupMenuBlend(const Value: boolean);
procedure SetContextMenuOptions(const Value: TSePopupMenuOptions);
protected
function GetEditRect: TRect; virtual;
function GetPasswordCharWidth: integer; virtual;
function GetCharX(A: integer): integer;
function GetCoordinatePosition(x: integer): integer;
function GetSelRect: TRect; virtual;
function GetAlignmentFlags: integer;

procedure PaintBuffer; override;

procedure PaintText; virtual;
procedure PaintBackground(Rect: TRect; Canvas: TCanvas); virtual;
procedure PaintSelectedText; virtual;
procedure DrawPasswordChar(SymbolRect: TRect; Selected: boolean); virtual;

function ValidText(NewText: WideString): boolean; virtual;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;

procedure BorderChanged; override;
procedure HasFocus; override;
procedure KillFocus; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; x, y:
int



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。