Dialog Box Resources

For more information, see the dialog box reference on the MSDN website.

General Description

Dialog resources can be used in your C/C++ source files with the DialogBox function. A dialog can contain up to 255 controls, defined by their IDs, so the controls must each have different IDs. All the same, there is a special ID, IDC_STATIC (whose value is -1), which is used for controls that do not need to be referred to by default. This ID can be assigned to more than one control. All of the units of size in the editor are not in pixels, but Dialog Units. It means the real window size will depend on the selected font. If you choose a bigger font, you will also get a bigger window, without changing its dimensions. The defaut font for the dialog boxes is Tahoma under Windows XP, and MS Sans Serif in sWindows 9x.

Creating a control

To insert a control, you first have to choose the type of control you want. For this, you have to use the Toolbox panel, on the right. Then, using the mouse, you must draw on the window where you want the control to be created (as if you were selecting some controls). Then the control will be created with the dimensions specified by the rectangle drawn with the mouse. The control's text, ID and style will be set to defaults. If you also want default dimension, you just have to click on the dialog window without dragging a rectangle.

Control selection

There are many ways to select controls in a dialog box:

Deleting controls

To delete some controls, you must select them, and then push the delete key or select it from the "Edit" menu.

Moving and resizing controls

It is possible to move or resize controls after they have been created. To resize a control, click on one of the squares drawn around the control. Note that some controls (icons and bitmaps) cannot be resized, and some others can only be resized vertically or horizontally. Only single controls may be resized; users may not select multiple controls and resize them simultaneously.

To move some controls, select them and drag them where you want. To have more precise control, you may use the arrow key on the keyboard. The controls may not extend beyond the client area of the window.

It is also possible to resize a control with the keyboard by using the arrow keys and the shift button down at the same time.

The property panel

The property panel describes the selected element's (control or dialog) properties. When multiple controls are selected, only the properties that are common to all of them will appear in the property panel. For example, if you select a button and an edit box, you will be able to edit the caption property, but not flat (which is only applicable to buttons).

The clipboard

It is possible to copy/cut/paste controls in a dialog box, or from a dialogbox to another one. This actually uses an internal clipboard, and it doesn't affect the contents of the Windows clipboard. All of the characteristic of the original controls (caption, ID, style) are saved, and the controls resulting from the paste action will be strictly identical to the originals (except for the controls' IDs, because they must all be different).

Undo buffer

All the modification made in a dialog box may be undone, by clicking on the undo button present in the toolbar, using the menu Edit->Undo, or by pressing Ctrl+Z. The undo buffer is unlimited, so it is always possible to come back to the original dialog box configuration. After undoing some operations, it is possible to redo them by using the redo button or by pressing Ctrl+Y.

Margins and grid

Marings and a grid have been added to make the control alignment easier. You can enable or disable it by using these toolbar buttons:

You can choose the margins and grid size, by using the menu Dialog>Configure grid and margin.


Copyright 2006-2008 | Contact.