📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComCtrls,CommCtrl;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function InputIP(var asIPAddr: string): Boolean;
var
frmInput: TForm;
hIPEdit: HWND;
begin
frmInput := CreateMessageDialog('请输入IP地址:', mtInformation, [mbOK, mbCancel]);
with frmInput do
try
Caption := 'IP地址输入窗口';
Width := 300;
Height := 110;
with TButton(Components[2]) do
begin
Left := 150;
Top := 23;
Width := 80;
Caption := '确定';
Left := Left + 50;
TabOrder := 2;
end;
with TButton(Components[3]) do
begin
Left := 150;
Top := 50;
Width := 80;
Caption := '取消';
Left := Left + 50;
TabOrder := 3;
end;
InitCommonControl(ICC_INTERNET_CLASSES);
hIPEdit := CreateWindow(WC_IPADDRESS, nil, WS_TABSTOP or WS_CHILD or WS_VISIBLE, 56, 32, 130, 23, Handle, 0, hInstance, nil);
Windows.SetFocus(hIPEdit);
Result := ShowModal = IDOK; //mrOK; IDCANCEL; IDYES
if Result then
begin
SetLength(asIPAddr, 15);
GetWindowText(hIPEdit, pChar(asIPAddr), 15);
end;
finally
Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var ipstr:string;
begin
ipstr:='127.0.0.1';
inputip(ipstr);
showmessage(ipstr);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -