Самоучитель по Delphi 7 для профессионалов



Создание нового компонента на базе элементов управления из библиотеки ComCtl32 - часть 4


property OnStartDock;

property OnStartDrag;

{ Published declarations }

property IPString; 

end;

procedure Register;

implementation

uses Graphics, commctrl, comctrls;

constructor TCustomlPEdit.Create(AOwner: TComponent); 

begin

inherited Create(AOwner);

FIPAddress := 0;

ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks, csOpaque];

Color := clBtnFace;

Width := 160;

Height := 25;

Align := alNone;

TabStop := True; end;

procedure TCustomlPEdit.CreateParams(var Params: TCreateParams);

 begin

InitCommonControl(ICC_INTERNET_CLASSES); 

inherited CreateParams(Params); CreateSubClass(Params, WC_IPADDRESS); 

with Params do 

begin

Style := WS_VISIBLE or WS_BORDER or WS_CHILD;

if NewStyleControls and CtlSD then

begin

Style := Style and not WS_BORDER; ExStyle := ExStyle or WS_EX_CLIENTEDGE; 

end; 

end;

 end;

procedure TCustomlPEdit.CreateWnd;

 var i: Integer; 

begin

inherited CreateWnd; Clear;

{ for i := 0 to 3 do

 begin

MinIP[i] := 0; MaxIP[i] := $FF; end; }

CurrentField := 0;

 end;

procedure TCustomlPEdit.WMGetDlgCode(var Message: TWMGetDlgCode);

 begin

inherited;

Message.Result := {Message.Result or} DLGC_WANTTAB; 

end;

procedure TCustomlPEdit.CNNotify(var Message: TWMNotify);

 begin

with Message.NMHdr" do

 begin case Code of

IPN_FIELDCHANGED : begin

FCurrentField := PNMIPAddress(Message.NMHdr)~.iField; {if Assigned(OnlpFieldChange) then

with PNMIPAdress(Message.NMHdr)^ do begin 

OnIPFieldChange(Self, iField, iValue);}

 end; 

end; 

end; 

end;

(procedure TCustomlPEdit.KeyDown(var Key: Word; Shift: TShiftState); 

begin

inherited KeyDown(Key, Shift);

 if Key = VKJTAB then if ssShift in Shift then

CurrentField := (CurrentField -1+4) mod 4

 else

CurrentField := (CurrentField + I) mod 4; end; }

{procedure TCustomlPEdit.CMWantSpecialKey(var Msg: TCMWantSpecialKey); 

begin

inherited;




Содержание  Назад  Вперед