时间: 2021-07-31 作者:daque
unit redit;interfaceuses windows, messages, sysutils, classes, graphics, controls, forms, dialogs, stdctrls;type tcustomredit = class(tcustomedit) private { private declarations } falignment:talignment; procedure setalignment(value: talignment); protected { protected declarations } property alignment: talignment read falignment write setalignment default taleftjustify; procedure createparams(var params: tcreateparams); override; public { public declarations } published { published declarations } end; tredit = class(tcustomredit) published { published declarations } property alignment; property anchors; property autoselect; property autosize; property bidimode; property borderstyle; property charcase; property color; property constraints; property ctl3d; property dragcursor; property dragkind; property dragmode; property enabled; property font; property hideselection; property imemode; property imename; property maxlength; property oemconvert; property parentbidimode; property parentcolor; property parentctl3d; property parentfont; property parentshowhint; property passwordchar; property popupmenu; property readonly; property showhint; property taborder; property tabstop; property text; property visible; property onchange; property onclick; property oncontextpopup; property ondblclick; property ondragdrop; property ondragover; property onenddock; property onenddrag; property onenter; property onexit; property onkeydown; property onkeypress; property onkeyup; property onmousedown; property onmousemove; property onmouseup; property onstartdock; property onstartdrag; end;procedure register;implementationprocedure tcustomredit.createparams(var params: tcreateparams);const alignments: array[boolean, talignment] of dword = ((es_left, es_right, es_center),(es_right, es_left, es_center));begin inherited createparams(params); with params do begin style := style or alignments[userighttoleftalignment, falignment]; end;end;procedure tcustomredit.setalignment(value:talignment);begin if falignment <> value then begin falignment := value; recreatewnd; end;end;procedure register;begin registercomponents('samples', [tredit]);end;end.上述不过给入门delphi控件创造者一点参考,固然不入方家法眼。不及之处,敬请教正。