Compartilhar via


How to Create a Configuration Manager Dialog Box

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

These procedures show you how to create a modeless dialog box assembly, in Microsoft System Center Configuration Manager 2007, by using Visual Studio.

The project has one class, SmsCustomDialog. Creating the dialog box is very similar to creating a property sheet, with the exception that you get the property manager from PageData

For more information about the property manager, see How to Use Objects Passed to a Configuration Manager Form.

After you have successfully built the dialog box assembly, you must do the following to integrate it into the Configuration Manager 2007 console:

  1. Define and deploy the form XML that links the selected action to the assembly you create in this topic. For more information, see How to Create Form XML for a Configuration Manager Dialog Box.

  2. Define and deploy the action XML for displaying the context menu that the user selects. For more information, see How to Create Action XML for a Configuration Manager Dialog Box.

When you have created the dialog assembly and XML, right-click a package in the Configuration Manager console tree Packages node, and then click Show my Dialog Box. A dialog box appears with a button on it. Clicking the button displays a message box containing the name of the package you selected.

Create the Control Class

The following procedure creates the control for the property sheet.

To create the Visual Studio project

  1. In Visual Studio 2005, on the File menu, point to New, and then click Project to open the New Project dialog box.

  2. From the list of Visual C#, Windows projects, select the Windows Control Library project template, and type ConfigMgrDialogControl in the Name box.

  3. Click OK to create the Visual Studio project.

  4. In Solution Explorer, right-click UserControl1.cs, click Rename, and change the name to ConfigMgrDialogControl.cs.

  5. In Solution Explorer, right-click References, and then click Add Reference.

  6. In the Add Reference dialog box, click the Browse tab, navigate to %ProgramFiles%\Microsoft Configuration Manager\AdminUI\bin and then select microsoft.configurationmanagement.dllmicrosoft.configurationmanagement.managementprovider.dll and Microsoft.ManagementConsole.dll. Click OK to add the assemblies as project references. If you do not find Microsoft.ManagementConsole.dll, add it from %Windir%\System32.

  7. In Solution Explorer, right-click ConfigMgrDialogControl.cs and then click View Code.

  8. In the source code, change the namespace to Microsoft.ConfigurationManagement.AdminConsole.ConfigMgrDialogBox

  9. Change the class ConfigMgrDialogControl so that it derives from SmsCustomDialog.

  10. In Solution Explorer, right-click ConfigMgrDialogControl.Designer.cs and then click View Code.

  11. In the source code, change the namespace to Microsoft.ConfigurationManagement.AdminConsole.ConfigMgrDialogBox

  12. Change the class ConfigMgrDialogControl so that it derives from SmsCustomDialog.

  13. In ConfigMgrDialogControl.cs, add the following code to initialize the control:

    public override bool Initialize(System.Reflection.Assembly assembly, SmsFormData formData, SmsPageData pageData)
    {
        base.Initialize(assembly, formData, pageData);
        return true;
    } 
    
  14. In Solution Explorer, right-click ConfigMgrDialogControl.cs and select View Designer.

  15. In the Toolbox, click the Common Controls tab, and then double-click Button. A button named button1 is added to your control on the User Control Designer.

  16. In the User Control Designer, double-click button1 and type the following code in the button1_Click method source code displayed:

       MessageBox.Show( PageData.PropertyManager["Name"].StringValue);
    

Deploy the Assembly

The following procedure builds and copies the assembly that you have created to the Configuration Manager console assemblies folder. For important information about deploying Configuration Manager console extensions, see Configuration Manager Console Extension Deployment.

To deploy the dialog box assembly

  1. Build the project, and depending on where you created your project, your Visual Studio installation, the assembly is created as \Visual Studio 2005\Projects\ConfigMgDialogControl\ConfigMgrDialogControl\bin\Debug\ConfigMgrDialogControl.dll.

  2. Copy the assembly to the folder %ProgramFiles%\Microsoft Configuration Manager\AdminUI\bin.

See Also

Concepts

How to Add a Property Page to an Existing Configuration Manager Property Sheet
How to Create Action XML for a Configuration Manager Property Sheet
How to Create Form XML for a Configuration Manager Property Sheet
How to Use Objects Passed to a Configuration Manager Form