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

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

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;
//Msg.Result: = Ord(Char(Msg.CharCode) = #9); end;}
procedure TCustomlPEdit.CMDialogChar(var Message: TCMDialogChar);
begin with Message do
if CharCode = VKJTAB then
begin
Message.Result: = 0; if GetKeyState(VK_SHIFT)<>0 then
begin
if (CurrentField=0) then Exit; CurrentField: = CurrentField – 1;
end
else
begin
if (CurrentField=3) then Exit; CurrentField: = CurrentField + 1;
end;
Message.Result: = 1; end //VK_TAB
else
inherited; end;
{procedure TCustomlPEdit.CMDialogKey(var Message: TCMDialogKey);
begin
if (Focused or Windows.IsChild(Handle, Windows.GetFocus))
and
Если Вы заметили ошибку, выделите, пожалуйста, необходимый текст и нажмите CTRL + Enter, чтобы сообщить об этом редактору.