TIPAddress

Source: source/classes/tipaddr.prg

Inherits from: TControl

TIPAddress wraps the Win32 IP address common control, providing a specialized input field for entering IPv4 addresses in dotted-decimal notation. Each of the four octets is edited in a separate field segment, with built-in validation and optional per-field range constraints.

Key DATA Members

DATATypeDescription
cIPAddressCharacterThe current IP address as a string (e.g., "192.168.1.1")
aFieldRangesArrayArray of { nMin, nMax } range arrays for each of the four octet fields

Methods

MethodDescription
New( nRow, nCol, oWnd, cIP, nW, nH )Create a new IP address input control
SetAddress( cIP )Set the control's IP address from a dotted-decimal string
GetAddress()Return the current IP address as a dotted-decimal string (e.g., "192.168.1.1")
ClearAddress()Clear all four octet fields to blank
IsBlank()Return .T. if all four octets are empty
SetRange( nField, nMin, nMax )Set the minimum and maximum values for a specific octet field (1-4)
SetFocus( nField )Set keyboard focus to a specific octet field (1-4)

Example: IP Address Input with Field Ranges

#include "FiveWin.ch"

function Main()

   local oWnd, oIP

   DEFINE WINDOW oWnd TITLE "IP Address" SIZE 350, 150

   @ 40, 20 IPADDRESS oIP ;
      SIZE 120, 25 OF oWnd ;
      ADDRESS "192.168.1.1"

   // Restrict the first octet to valid private ranges
   oIP:SetRange( 1, 10, 192 )
   oIP:SetRange( 4, 1, 254 )

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also