TEdit에서 파생 된 새 구성 요소를 만들었습니다. 아래 코드에서 AllowValues를으로 설정 한 후 MaxLength 속성을 10으로 설정합니다.CustomComponent (TEDIT) 설정 MaxLength 속성이 작동하지 않습니다.
폼에 구성 요소를 설정하고 AllowValues를 true로 설정하고을 실행하고 응용 프로그램을 실행하고 편집 상자에서 10 자 이상을 허용합니다. 내 코드가 뭐가 잘못 됐어?
unit DummyEdit;
interface
uses
SysUtils, Classes, Controls, StdCtrls,Dialogs,Windows,Messages;
type
TDUMMYEdit = class(TEdit)
private
{ Private declarations }
FAllowValues : Boolean;
FMaxLength: Integer;
Procedure SetAllowValues(Value : Boolean);
procedure SetMaxLength(Value: Integer);
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
Property AllowValues : Boolean read FAllowValues write SetAllowValues;
property MaxLength: Integer read FMaxLength write SetMaxLength default 0;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('DUMMY', [TDUMMYEdit]);
end;
{ TDUMMYEdit }
procedure TDUMMYEdit.SetAllowValues(Value: Boolean);
begin
if FAllowValues <> value then
FAllowValues := Value;
if FAllowValues then
MaxLength := 10
else
MaxLength := 0;
end;
procedure TDUMMYEdit.SetMaxLength(Value: Integer);
begin
if FMaxLength <> Value then
begin
FMaxLength := Value;
if HandleAllocated then SendMessage(Handle, EM_LIMITTEXT, Value, 0);
end;
end;
end.
구성 요소 작성에 초보자이며 놀고 있습니다. 나는 Createwnd를 점검 할 것이다. – DelphiLearner
내가 작동하는 MaxLength 속성을 제거하면. – DelphiLearner
다행입니다. 나는 당신의 원래 코드와'CreateWnd'를 가지고 솔루션을 추가했다. – nil