Erstellen eines IP-Adresssteuer steuerelements

In diesem Thema wird veranschaulicht, wie sie eine Instanz eines IP-Adresssteuer steuerelements erstellen.

Wichtige Informationen

Technologien

Voraussetzungen

  • C/C++
  • Windows Benutzeroberfläche-Programmierung

Anweisungen

Laden Sie vor dem Erstellen eines IP-Adresssteuerelementes die allgemeine Steuerelement-DLL, indem Sie InitCommonControlsEx aufrufen. Verwenden Sie dann die Funktion CreateWindow oder CreateWindowEx, um ein Instanz-IP-Adresssteuersystem zu erstellen. Der Klassenname für das Steuerelement ist WC _ IPADDRESS. Verwenden Sie den WS _ CHILD-Stil, da dem IP-Adresssteuer steuerelement keine bestimmte Stilkonst constant zugeordnet ist.

Im folgenden C++-Codebeispiel ruft die anwendungsdefinierte Funktion zuerst InitCommonControlsEx auf und legt den dwICC-Member der INITCOMMONCONTROLSEX-Struktur auf COD INTERNET _ _ CLASSESfest, der die IP-Adressklasse angibt. Anschließend wird CreateWindowEx aufgerufen, um eine Instanz des IP-Adresssteuer steuerelements zu erstellen.

// CreateIPAdressFld - creates a IPAddress control.
// Returns the handle to the new control
// TO DO:  calling procedure needs to check whether the handle is NULL, in case 
// of an error in creation.
// int xcoord, ycoord the coordinates of location of the control in the parent window
// HINST hInst is the global handle to the application instance.
// HWND  hWndParent is the handle to the control's parent window. 
//
//
HWND CreateIPAddressFld (HWND hwndParent, int xcoord, int ycoord) 
{     
     
    INITCOMMONCONTROLSEX icex;
    
    // Ensure that the common control DLL is loaded. 
    icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icex.dwICC  = ICC_INTERNET_CLASSES ;
    InitCommonControlsEx(&icex); 
    
    // Create the IPAddress control.        
    HWND hWndIPAddressFld = CreateWindow(WC_IPADDRESS, 
                                L"", 
                                WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, 
                                xcoord, 
                                ycoord,
                                150, 
                                20,  
                                hwndParent, 
                                NULL, 
                                hInst, 
                                NULL); 
                                
    return (hWndIPAddressFld);
}

Referenz zur IP-Adresssteuerung

Informationen zu IP-Adresssteuerelementen

Verwenden von IP-Adresssteuerelementen