Adding Custom Controls

When a standard control — such as a list box or edit field — doesn't meet your needs, you can create a custom control that performs a specific task. For example, the buttons on a toolbar can be custom controls.

The code that defines a custom control resides in either a DLL or, occasionally, in the .EXE file that calls the dialog box. The Dialog Editor supports custom-control DLLs and temporary custom controls, as described in the following table:

Custom Control Description
DLL A dynamic-link library (DLL) that defines one or more custom control classes.
Temporary A place holder for a custom control defined elsewhere. The Dialog Editor creates a gray rectangle to indicate the control's location and size. You can set the temporary control's class name, size, and other attributes to match the ones used by the final custom control.

After a custom-control DLL is opened by the Dialog Editor, it remains available between Dialog Editor sessions. Temporary custom controls are not saved between sessions.

When the Dialog Editor opens a .DLG file that contains a custom control, it searches its list of custom-control DLLs to find a match. If a match is found (the controls have the same class name), the Dialog Editor uses the information in the DLL to display the custom control. If a match is not found, the Dialog Editor creates a temporary custom control with the given class name.

The Dialog Editor replaces any temporary custom control during an editing session when you open a DLL custom control with the same name.

    To add a new temporary custom control
  1. From the File menu, click New Custom. The New Temporary Custom Control dialog box appears.
  2. Type a name for the custom control in the Class Name edit field.
  3. Optionally, change the other Control Defaults.
  4. Choose OK.

The Dialog Editor adds the temporary control to the list of available custom controls. To use the temporary control, click the custom control tool. You can use the following method to add either a temporary custom control or a custom control DLL to a dialog box:

    To add a custom control
  1. Click the Custom Control (bottom right) tool on the toolbox.

    If you have more than one custom control installed (either temporary or from DLLs), the Select Custom Control dialog box is displayed. If you only have one custom control, skip to Step 6.

  2. From the Available Controls list box, select the custom control you want to add to the dialog box.
  3. Choose OK.
  4. Move the cursor into the dialog. A rectangle with the "move" icon inside replaces the cursor.
  5. Press and hold the mouse button to see an outline of the control. The coordinates for the location of the control are displayed in the properties bar.

    You cannot move the outlined control outside of the dialog once you have pressed the mouse button.

  6. Drop the control by releasing the mouse button. The custom control is centered over the point where you released the mouse button.