Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 查找FOSS IPv4地址选择器VCL组件_Delphi_Vcl - Fatal编程技术网

Delphi 查找FOSS IPv4地址选择器VCL组件

Delphi 查找FOSS IPv4地址选择器VCL组件,delphi,vcl,Delphi,Vcl,严格来说,在保留地址范围内使用IPv4就足够了。我还不知道我是否会使用A类、B类或C类(可能是C类,但是…),所以能够处理所有的问题将是一个额外的收获 如果我还可以输入类似“localhost”的内容,那么就有额外的奖励,尽管我可以不输入这些内容 因此,最低要求是指定192.xxx.xxx.xxx,并确保xxx不超过255 当然,我可以用一些蒙版编辑来完成一个,但肯定有人以前发明过那个特别的(FOSS)轮子吗 self注意:如果您确实需要对其进行编码,那么它看起来很有用如何从中尝试?它具有自动

严格来说,在保留地址范围内使用IPv4就足够了。我还不知道我是否会使用A类、B类或C类(可能是C类,但是…),所以能够处理所有的问题将是一个额外的收获

如果我还可以输入类似“localhost”的内容,那么就有额外的奖励,尽管我可以不输入这些内容

因此,最低要求是指定192.xxx.xxx.xxx,并确保xxx不超过255

当然,我可以用一些蒙版编辑来完成一个,但肯定有人以前发明过那个特别的(FOSS)轮子吗


self注意:如果您确实需要对其进行编码,那么它看起来很有用

如何从中尝试?它具有自动范围值校正功能,并源自标准的Windows IP编辑框。

Windows具有内置的。您可以将其包装在自定义
TWinControl
子体组件中,以便于访问和重用,例如:

type
  TIPAddressFieldChange = procedure(Sender: TObject; Field: Integer; Value: Integer) of object;

  TIPAddress = class(TWinControl)
  private
    FOnFieldChange: TIPAddressFieldChange;
    function GetIP: String; 
    function GetIsEmpty: Boolean; 
    procedure SetIP(const Value: String);    
  protected
    procedure CreateParams(var Params: TCreateParams); override;
    procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
    procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE; 
    procedure WMSetFont(var Message: TWMSetFont); message WM_SETFONT;
  public
    constructor Create(Owner: TComponent); override; 
    procedure Clear;
    property IP: String read GetIP write SetIP; 
    property IsEmpty: Boolean read GetIsEmpty; 
  published:
    property OnFieldChange: TIPAddressFieldChange read FOnFieldChange write FOnFieldChange;
  end; 

使用
Commctrl;
构造函数TIPAddress.Create(所有者:TComponent);
开始
继承;
InitCommonControl(ICC_互联网_类};
结束;
过程TIPAddress.CreateParams(变量参数:TCreateParams);
开始
继承;
CreateSubClass(参数,WC_IPADDRESS);
参数样式:=WS_CHILD或WS_TABSTOP或WS_VISIBLE;
如果NewStyleControls和Ctl3D
开始
Params.Style:=Params.Style,而不是WS_BORDER;
Params.ExStyle:=Params.ExStyle或WS_EX_CLIENTEDGE;
结束;
Params.WindowClass.style:=Params.WindowClass.style和not(CS_HREDRAW或CS_VREDRAW);
结束;
程序提示。清除;
开始
执行(IPM_CLEARADDRESS,0,0);
结束;
函数TIPAddress.GetIP:String;
变量
dwIp:DWORD;
开始
dwIp:=0;
执行(IPM_GETADDRESS,0,LPARAM(@dwIp));
结果:=格式(“%d.%d.%d.%d’,[FIRST_IPADDRESS(dwIp),SECOND_IPADDRESS(dwIp),
第三个IP地址(dwIp),第四个IP地址(dwIp)];
结束;
函数TIPAddress.GetIsEmpty:布尔值;
开始
结果:=执行(IPM_为空白,0,0)0;
结束;
过程TIPAddress.SetIP(常量值:字符串);
变量
dwIP:LPARAM;
开始
使用TStringList。创建并尝试
分隔符:=';
StrictDelimiter:=True;
DelimitedText:=值;
断言(计数=4);
dwIP:=MAKEIPADDRESS(strotint(Strings[0])、strotint(Strings[1])、strotint(Strings[2])、strotint(Strings[3]);
最后
自由的
结束;
执行(IPM_设置地址,0,dwIP);
结束;
程序TIPAddress.CNNotify(var消息:TWMNotify);
开始
继承;
如果(Message.NMHdr^.code=IPN_FIELDCHANGED)和分配(FOnFieldChange),则
开始
使用PNMIPAddress(Message.NMHdr)^do
FOnFieldChange(Self、iField、iValue);
结束;
结束;
过程TIPAddress.WMGetDlgCode(变量消息:TMessage);
开始
继承;
Message.Result:=Message.Result或DLGC_WANTARROWS;
结束;
过程TIPAddress.WMSetFont(变量消息:TWMSetFont);
变量
LF:LOGFONT;
开始
如果GetObject(Message.Font,SizeOf(LF),@LF)为0,则
开始
Message.Font:=CreateFontIndirect(LF);
继承;
结束;
结束;

+1和答案,因为它是独立的(不确定其他建议是否需要我安装所有JVCL)。谢谢你,不客气。它实际上基于与此处发布的Remy相同的内容;在Windows IP地址控件上,但它只是包装为组件。
uses
  Commctrl;

constructor TIPAddress.Create(Owner: TComponent);
begin
  inherited;
  InitCommonControl(ICC_INTERNET_CLASSES}; 
end;

procedure TIPAddress.CreateParams(var Params: TCreateParams);
begin
  inherited;
  CreateSubClass(Params, WC_IPADDRESS); 
  Params.Style := WS_CHILD or WS_TABSTOP or WS_VISIBLE; 
  if NewStyleControls and Ctl3D then
  begin 
    Params.Style := Params.Style and not WS_BORDER; 
    Params.ExStyle := Params.ExStyle or WS_EX_CLIENTEDGE; 
  end;
  Params.WindowClass.style := Params.WindowClass.style and not (CS_HREDRAW or CS_VREDRAW); 
end;

procedure TIPAddress.Clear;
begin
  Perform(IPM_CLEARADDRESS, 0, 0);
end;

function TIPAddress.GetIP: String;
var
  dwIp: DWORD; 
begin
  dwIp := 0; 
  Perform(IPM_GETADDRESS, 0, LPARAM(@dwIp)); 
  Result := Format('%d.%d.%d.%d', [FIRST_IPADDRESS(dwIp), SECOND_IPADDRESS(dwIp), 
THIRD_IPADDRESS(dwIp), FOURTH_IPADDRESS(dwIp)]); 
end;

function TIPAddress.GetIsEmpty: Boolean;
begin
  Result := Perform(IPM_ISBLANK, 0, 0) <> 0; 
end;

procedure TIPAddress.SetIP(const Value: String);
var
  dwIP: LPARAM;
begin
  with TStringList.Create do try
    Delimiter := '.';
    StrictDelimiter := True;
    DelimitedText := Value;
    Assert(Count = 4);
    dwIP := MAKEIPADDRESS(StrToInt(Strings[0]), StrToInt(Strings[1]), StrToInt(Strings[2]), StrToInt(Strings[3]));
  finally
    Free;
  end;
  Perform(IPM_SETADDRESS, 0, dwIP);
end;

procedure TIPAddress.CNNotify(var Message: TWMNotify);
begin
  inherited;
  if (Message.NMHdr^.code = IPN_FIELDCHANGED) and Assigned(FOnFieldChange) then
  begin
    with PNMIPAddress(Message.NMHdr)^ do
      FOnFieldChange(Self, iField, iValue);
  end;
end;

procedure TIPAddress.WMGetDlgCode(var Message: TMessage);
begin
  inherited; 
  Message.Result := Message.Result or DLGC_WANTARROWS; 
end;

procedure TIPAddress.WMSetFont(var Message: TWMSetFont); 
var 
  LF: LOGFONT; 
begin 
  if GetObject(Message.Font, SizeOf(LF), @LF) <> 0 then
  begin 
    Message.Font := CreateFontIndirect(LF); 
    inherited; 
  end; 
end;