In web programs, we often encounter situations where users are required to enter an IP address. However, C + + Builder does not provide us with a control that can be used to enter IP strings, so we have to use the Tedit control (single-line text box) to accept the IP string that the user enters. However, using Tedit to enter IP strings is not a good idea, because it is very inconvenient to handle. In fact, beside us there is a Windows control that is specifically used to enter IP strings, like the controls that enter IP in the Internet Protocol (TCP/IP) properties in the network link properties. IP controls reject illegal IP strings (only digits between 0~255 in each section); it allows you to easily get the IP values (32-bit integers) of IP strings in the control, which eliminates the hassle of switching between IP strings and IP values; You can also limit the range of IP controls that can be entered in an IP control. In this article, I'll show you how to use the IP controls for windows in our C + + Builder programs.
There are two very important dynamic join libraries in Windows: Commctrl.dll and Comctl32.dll, which are custom control libraries for Windows (Windows Common Controls). The Custom control library contains many commonly used Windows controls, such as Statusbar,coolbar,hotkey, and in C + + builder, most of these controls have been packaged as visual controls. After Microsoft launched Internet Explorer 3, a number of controls were added to the custom control library, including the IP controls for Windows (IP address edit control).
Initializing the Windows custom control Library
Windows provides two API functions, InitCommonControls and Initcommoncontrolsex, to initialize a custom control library. It is not hard to see from the name the relationship between these two API functions: the latter is the enhancement of the former. If you want to use IP controls in your program, you must use Initcommoncontrolsex to complete the initialization of your custom control libraries and classes. The prototype of the function Initcommoncontrolsex is as follows:
typedef struct TAGINITCOMMONCONTROLSEX {
DWORD dwsize; Size of this structure