怎样把矩形edit变成横线输入??????(100分)

  • 主题发起人 主题发起人 tbp99
  • 开始时间 开始时间
T

tbp99

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样把矩形edit变成横线输入??????
 
改他的passwordchar为横线就行了
 
把Edit的BorderStyle的属性设为bsNone,颜色设成根背景色一样,下面再放个Bevel就可以了阿
 
1 将Edit.Color设成与其背景色一致
2 设Edit.BorderStyle:=bsNone
3 放一个Shape
Shape.Height:=1
4 再把Shape放在Edit的下面,调整Edit的高度(Edit.AutoSize:=False)
5 把它们作成一个临时控件就好用了:Component|Create Component Template
OK
 
随手写个控件。

unit EditLine;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls, Graphics, Forms;

type
TEditLine = class(TEdit)
private
{ Private declarations }
FCanvas: TCanvas;
protected
{ Protected declarations }
procedure WMPaint(var Msg: TMessage);message WM_PAINT;
public
{ Public declarations }
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
end;

procedure Register;

implementation

constructor TEditLine.Create(AOwner: TComponent);
begin
inherited;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := self;
self.Color := clBtnFace;
self.BorderStyle := bsNone;
end;

destructor TEditLine.Destroy;
begin
FCanvas.Free;
inherited;
end;


procedure TEditLine.WMPaint(var Msg: TMessage);
begin
inherited;
FCanvas.MoveTo(0,Height-2); //这里开始画线
FCanvas.LineTo(Width,Height-2);
end;

procedure Register;
begin
RegisterComponents('dwh', [TEditLine]);
end;

end.
 

Similar threads

后退
顶部