[解答]Edit如何靠右显示?? |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
原問題
Edit如何靠右显示?? http://delphi.ktop.com.tw/board.php?cid=30&fid=1498&tid=92702 Form : http://www.swissdelphicenter.ch/torry/showcode.php?id=714 ...create a TEdit with definable text alignment? Author: Simon Grossenbacher Homepage: http://www.swissdelphicenter.ch [ Print tip ] Tip Rating (30): { Dazu müssen die CreateParams von der Klasse TEdit überschrieben werden. Folgende Unit kann als Komponente installiert werden. All you have to do is to verride the CreateParams of the class TEdit. Install the following unit as a component. } unit AlignEdit; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TAlign = (eaLeft, eaCenter, eaRight); TAlignEdit = class(TEdit) private { Private-Deklarationen } FAlign: TAlign; procedure SetAlign(const Value: TAlign); protected { Protected-Deklarationen } procedure CreateParams(var Params: TCreateParams); override; public { Public-Deklarationen } constructor Create(AOwner: TComponent); override; published { Published-Deklarationen } property Alignment: TAlign read FAlign write SetAlign default eaLeft; end; procedure Register; implementation constructor TAlignEdit.Create(Aowner: TComponent); begin inherited Create(AOwner); FAlign := eaLeft; end; procedure TAlignEdit.SetAlign(const Value: TAlign); begin if FAlign <> Value then begin FAlign := Value; RecreateWnd; end; end; procedure TAlignEdit.CreateParams(var Params: TCreateParams); begin inherited; case FAlign of eaLeft: Params.Style := Params.Style or ES_LEFT; eaCenter: Params.Style := Params.Style or ES_CENTER; eaRight: Params.Style := Params.Style or ES_RIGHT; end; end; procedure Register; begin RegisterComponents('SwissDelphiCenter', [TAlignEdit]); end; end.
------
努力會更接近成功 編輯記錄
pceyes 重新編輯於 2008-03-02 16:58:22, 註解 無‧
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |