Unit ipinput;
Interface
Uses Windows, Dialogs, Sysutils, Classes, Graphics, Forms, Controls, Stdctrls, Buttons, Extctrls, Comctrls, CommCtrl
type TInputIpFrm = class (TForm) SpdBfdftnCancle: TLabel; SpdBtnOK: TSpeedButton; SpdBtnCancle: TSpeedButton; procedure FormShow (Sender: TObject); procedure SpdBtnOKClick (Sender: TObject); procedure SpdBtnCancleClick (Sender: TObject); procedure FormDestroy (Sender: TObject) Procedure formcreate (sender: TOBJECT); Private
Public iPedit: hwnd; m_communicationip: string; ipaddress: integer; procedure getipnum (Striniip: string; out nfirst, nsecond, nthird, nforth: integer);
VAR INPUTIPFRM: TINPUTIPFRM;
IMPLEMENTATION
{$ R * .dfm}
procedure TInputIpFrm.GetIPNum (strIniIP: String; out nFirst, nSecond, nThird, nForth: integer); var str, strNum, strTemp: String; begin str: =; try strTemp '.': = strPos (PChar (strIniIP), PChar (STR)); Strnum: = COPY (Striniip, 1, Length (Striniip) - length (strTemp)); nfirst: = start (Strnum);
Striniip: = COPY (Strtemp, 2, Length (strTemp)); Strtemp: = Strpos (Pchar (Striniip), PCHAR (STR)); Strnum: = Copy (Striniip, 1, Length (Striniip) - length (strTemp)) NSECOND: = strnum;
Striniip: = COPY (Strtemp, 2, Length (strTemp)); Strtemp: = Strpos (Pchar (Striniip), PCHAR (STR)); Strnum: = Copy (Striniip, 1, Length (Striniip) - length (strTemp)) Nthird: = start (strnum);
Striniip: = COPY (Strtemp, 2, Length (strTemp)); Strtemp: = Strpos (Pchar (Striniip), PCHAR (STR)); Strnum: = Copy (Striniip, 1, Length (Striniip) - length (strTemp)) Nforth: = start (Strnum); Except nfirst: = 192; nsecond: = 168; nthird: = 0; nstird: = 198; showMessage (''); END;
Procedure TinputiPfrm.FormShow (Sender: Tobject); VAR NFirst, NSECOND, NTHIRD, NFORTH: Integer; Begin GetIPNUM (M_CommunicationIP, NFirst, NSECOND, NTHIRD, NFORTH);
ipaddress: = makeipaddress (nfirst, nsecond, nthird, nforth); // Initializing IP address
SendMessage (iPEDIT, IPM_SETADDRESS, 0, IPADDRESS); // Show The Current Address SendMessage (iPedit, IPM_SETFOCUS, 0, 0); // Select the first field {} end;
Procedure TinputiPfrm.SpdbTnokClick (Sender: TOBJECT); Begin SendMessage (iPedit, IPM_Getaddress, 0, Longint (@ipaddress));
if ipAddress = 0 then begin beep; SendMessage (ipEdit, IPM_SETFOCUS, 0,0); // select the first field Application.MessageBox; modalResult (, 'warning', mb_OK MB_ICONWARNING 'IP addresses illegal!'): = mrNone; '.' '.' '.': end else begin m_CommunicationIP = IntToStr (FIRST_IPADDRESS (ipAddress)) IntToStr (SECOND_IPADDRESS (ipAddress)) IntToStr (THIRD_IPADDRESS (ipAddress)) IntToStr (FOURTH_IPADDRESS (ipAddress)); {} Self.close;
END;
Procedure TinputiPfrm.spdbtncancleClick (Sender: TOBJECT); Begin Self.Close;
Procedure TinputiPfrm.formDestroy (Sender: TOBJECT); Begin InputiPFRM: = NIL; END;
procedure TInputIpFrm.FormCreate (Sender: TObject); begin InitCommonControl (ICC_INTERNET_CLASSES); ipEdit: = CreateWindow (WC_IPADDRESS, nil, WS_CHILD or WS_VISIBLE, 65,20,160,25, self.Handle, 0, hInstance, nil);
END;
End.