我有个简单问题,快来拿分!(80分)

  • 主题发起人 主题发起人 billxu
  • 开始时间 开始时间
B

billxu

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样使TEdit控件里的字符右对齐,象计算器一样。<br>请不要用其他控件。
 
如果不用其他控件或自己改进是肯定不行了。
 
unit REdit;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TREdit = class(TEdit)<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; protected<br>&nbsp; &nbsp; { Protected declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; procedure CreateParams(var Params: TCreateParams);override;<br>&nbsp; published<br>&nbsp; &nbsp; { Published declarations }<br>&nbsp; end;<br><br>procedure Register;<br><br>implementation<br><br>procedure Register;<br>begin<br>&nbsp; RegisterComponents('Free', [TREdit]);<br>end;<br><br>procedure TREdit.CreateParams(var Params: TCreateParams);<br>begin<br>&nbsp; inherited;<br>&nbsp; Params.Style:=Params.Style or ES_RIGHT;<br>end;<br><br><br>end.
 
多人接受答案了。
 
在TEdit里实现右对齐 &nbsp;<br>李颖<br><br><br>摘 要:<br>关键字:右对齐 Edit<br>类 别:用户界面<br>&nbsp;<br>&nbsp;<br>procedure TForm1.Button1Click(Sender: TObject); <br>var<br>&nbsp; ExStyle: DWORD; <br>begin<br>&nbsp; ExStyle := DWORD(GetWindowLong(Edit1.Handle, GWL_EXSTYLE)) and (not WS_EX_RIGHT) and<br>&nbsp; &nbsp; (not WS_EX_RTLREADING) and (not WS_EX_LEFTSCROLLBAR);<br>&nbsp; ExStyle := ExStyle or WS_EX_RIGHT;<br>&nbsp; SetWindowLong(Edit1.Handle, GWL_EXSTYLE, ExStyle);<br>&nbsp; Edit1.Invalidate; <br>end;<br>&nbsp;<br>
 
后退
顶部