unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Commctrl;
type
TForm2 =
class(TForm)
ButtonCreateInput: TButton;
ButtonAcceptInput: TButton;
procedure ButtonCreateInputClick(Sender: TObject);
procedure ButtonAcceptInputClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
MyIPEdit: HWND;
MyIPAddress: integer;
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.ButtonCreateInputClick(Sender: TObject);
Const
x=10;
y=10;
w=130;
h=22;
begin
MyIPAddress := MAKEIPADDRESS(127, 0, 0, 1);
// Vorbelegung
InitCommonControl(ICC_INTERNET_CLASSES);
MyIPEdit := CreateWindow(WC_IPADDRESS,
nil, WS_CHILD
or WS_VISIBLE, x, y,
w, h, self.Handle, 0, hInstance,
nil);
SendMessage(MyIPEdit, IPM_SETADDRESS, 0, MyIPAddress);
// Vorbelegung eintragen wenn gewünscht
SendMessage(MyIPEdit, IPM_SETFOCUS, 0, 0);
end;
procedure TForm2.ButtonAcceptInputClick(Sender: TObject);
begin
SendMessage(MyIPEdit, IPM_GETADDRESS, 0, longint(@MyIPAddress));
if MyIPAddress = 0
then
begin
Showmessage('
Keine IP-Adresse');
SendMessage(MyIPEdit, IPM_SETFOCUS, 0, 0);
end
else
Showmessage('
IP: ' + IntToStr(FIRST_IPADDRESS(MyIPAddress)) + '
.' + IntToStr
(SECOND_IPADDRESS(MyIPAddress)) + '
.' + IntToStr
(THIRD_IPADDRESS(MyIPAddress)) + '
.' + IntToStr
(FOURTH_IPADDRESS(MyIPAddress)) + '
.')
end;
end.