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
| DATA | Type | Description |
|---|---|---|
cIPAddress | Character | The current IP address as a string (e.g., "192.168.1.1") |
aFieldRanges | Array | Array of { nMin, nMax } range arrays for each of the four octet fields |
Methods
| Method | Description |
|---|---|
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
- TIPAddress wraps the Win32
SysIPAddress32common control. It handles IPv4 addresses only. - Use
SetRange( nField, nMin, nMax )to constrain individual octets.nFieldis 1-based (1 = leftmost octet, 4 = rightmost). - The
GetAddress()method returns an empty string if the control is blank; useIsBlank()to check before reading. - Navigation between octet fields is automatic: pressing . (period) or → moves to the next field.
- The ADDRESS clause in the
@ ... IPADDRESScommand sets the initial IP value.