IP地址输入框是怎么做的?

Thread 2001-03-08 11:26:00
...全文
312 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yhec 2001-03-14
  • 打赏
  • 举报
回复
有点吓人,VCL应封装一下这个控件
italian 2001-03-08
  • 打赏
  • 举报
回复
我也学会了。谢谢。
BCB 2001-03-08
  • 打赏
  • 举报
回复
前一个方案,报上介绍过,实在太长,没有必要;
后一个方案,用TMaskEdit控件:
1.将TMaskEdit的Font设成“宋体”,否则,点与点太近,就不像了;
2.将TMaskEdit的EditMask设成: 999.999.999.999;1;
3.在设置EditMask将Character for Blanks的下划线一定要去掉(要反复几次);
2001Sky 2001-03-08
  • 打赏
  • 举报
回复
同意
yhec 2001-03-08
  • 打赏
  • 举报
回复
API中有专门的IP控件支持,
但DELPHI中没有直接控件支持,可用TMaskEdit模拟,可以仿得一模一样
Haha_kylix 2001-03-08
  • 打赏
  • 举报
回复
装上试试吧,这只是一个非常简单的实现
unit IpAddress;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, CommCtrl, ComCtrls, Controls,
Forms, Dialogs;

type
TIpAddress = class(TWinControl)
private
{ Private declarations }
FIPValue:DWORD;
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure DestroyWnd; override;
//procedure WMSize(var Message:TWMSize);Message WM_SIZE;
public
constructor Create(AOwner: TComponent); override;
procedure SetIPValue(Value:DWORD);
procedure Clear;
published
{ Published declarations }
property Align;
property Anchors;
property BorderWidth;
property Color;
property Font;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Hint;
property Constraints;
property ParentShowHint;
property IPValue:DWORD read FIPValue write SetIPValue;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnContextPopup;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;

procedure Register;

implementation

procedure TIpAddress.CreateParams(var Params:TCreateParams);
begin
Inherited CreateParams(Params);
CreateSubclass(Params,WC_IPADDRESS);
end;

procedure TIpAddress.CreateWnd;
begin
Inherited CreateWnd;
end;

procedure TIpAddress.DestroyWnd;
begin
Inherited DestroyWnd;
end;

constructor TIpAddress.Create(AOwner: TComponent);
begin
InitCommonControl(ICC_INTERNET_CLASSES);
Inherited Create(AOwner);
Height:=24;
Width:=120;
FIPValue:=0;
end;

{
procedure TIpAddress.WMSize(var Message:TWMSize);
begin
if HandleAllocated then
begin
Inherited;
SendMessage(Handle,IPM_SETADDRESS,0,FIPValue);
end;
end;
}
procedure TIpAddress.SetIPValue(Value:DWORD);
begin
if Value<>FIPValue then
begin
FIPValue:=Value;
SendMessage(Handle,IPM_SETADDRESS,0,Value);
end;
end;

procedure TIpAddress.Clear;
begin
SendMessage(Handle,IPM_CLEARADDRESS,0,0);
end;

procedure Register;
begin
RegisterComponents('Gan', [TIpAddress]);
end;

end.