Using the IP controls provided by the Windows system

Source: Internet
Author: User

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:


DWORD dwsize; Size of this structure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.