어렵게 어렵게 맹글었는데 edit의 OnKeyPress Event를 맹글수가 없어요.
좀 도와 주세요. 무지 무지 급한디......
unit LsyEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
Math, ExtCtrls;
type
TLsyEdit = class(TCustomPanel)
private
FNo1 : TEdit;
FNo2 : TEdit;
procedure WMPaint(var Msg:TWMPaint); message WM_PAINT;
procedure DoPaintPanel;
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample', [TLsyEdit]);
end;
{ TLsyEdit }
constructor TLsyEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BevelInner := bvNone;
BevelOuter := bvNone;
TabStop := false;
Width := 60;
Height := 21;
FNo1 := TEdit.Create(Self);
FNo1.SetBounds(0, 0, floor(width * 6 / 10),Height);
FNo1.Parent := self;
FNo1.Visible := true;
FNo2 := TEdit.Create(Self);
FNo2.SetBounds(FNo1.Left + FNo1.Width + 5, 0, floor(width * 4 / 10),Height);
FNo2.Parent := self;
FNo2.Visible := true;
Caption := '';
end;
destructor TLsyEdit.Destroy;
begin
FNo1.Free;
FNo2.Free;
inherited Destroy;
end;
procedure TLsyEdit.WMPaint(var Msg: TWMPaint);
begin
inherited;
Caption := '';
DoPaintPanel;
end;
procedure TLsyEdit.DoPaintPanel;
var
DC : HDC;
begin
Color := (Parent as TWinControl).Brush.Color;
FNo1.SetBounds(0, 0, floor(width * 6 / 10),Height);
FNo2.SetBounds(FNo1.Left + FNo1.Width + 5, 0, floor(width * 4 / 10),Height);
DC := GetDC(Handle);
MovetoEx(DC,FNo2.Left - 5,floor(Height / 2),nil);
LineTo (DC,FNo2.Left - 2,floor(Height / 2));
ReleaseDC(Handle,DC);
end;
end.
Example입니다. 즐거운 하루되세요.
unit LsyEditpas;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
Math, ExtCtrls;
type
TLsyEdit = class(TCustomPanel)
private
FNo1 : TEdit;
FNo2 : TEdit;
procedure WMPaint(var Msg:TWMPaint); message WM_PAINT;
procedure DoPaintPanel;
{ Private declarations }
protected
{ Protected declarations }
procedure KeyPress(var Key: Char); override; //***** 다음과 같이 쓰세요 *****
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{ Public declarations }
published
{ Published declarations }
property OnKeyPress; //***** 다음과 같이 쓰세요 *****
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample', [TLsyEdit]);
end;
{ TLsyEdit }
constructor TLsyEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BevelInner := bvNone;
BevelOuter := bvNone;
TabStop := false;
Width := 60;
Height := 21;
FNo1 := TEdit.Create(Self);
FNo1.SetBounds(0, 0, floor(width * 6 / 10),Height);
FNo1.Parent := self;
FNo1.Visible := true;
FNo2 := TEdit.Create(Self);
FNo2.SetBounds(FNo1.Left + FNo1.Width + 5, 0, floor(width * 4 / 10),Height);
FNo2.Parent := self;
FNo2.Visible := true;
Caption := '';
end;
destructor TLsyEdit.Destroy;
begin
FNo1.Free;
FNo2.Free;
inherited Destroy;
end;
procedure TLsyEdit.WMPaint(var Msg: TWMPaint);
begin
inherited;
Caption := '';
DoPaintPanel;
end;
procedure TLsyEdit.DoPaintPanel;
var
DC : HDC;
begin
Color := (Parent as TWinControl).Brush.Color;
FNo1.SetBounds(0, 0, floor(width * 6 / 10),Height);
FNo2.SetBounds(FNo1.Left + FNo1.Width + 5, 0, floor(width * 4 / 10),Height);
DC := GetDC(Handle);
MovetoEx(DC,FNo2.Left - 5,floor(Height / 2),nil);
LineTo (DC,FNo2.Left - 2,floor(Height / 2));
ReleaseDC(Handle,DC);
end;
//***** 다음과 같이 쓰세요 *****
procedure TLsyEdit.KeyPress(var Key: Char);
begin
inherited;
//적당히 사용하실 내용을 코딩하세요.
end;
end.