The DIALOGS.H File

The .H file contains all the symbolic names you've defined for the current dialogs.

When you create a dialog control, it gets an ID number. You can also assign a symbolic name to the control, and can refer to the control by name or number in your code. The .H file associates symbolic names with corresponding ID numbers.

A typical .H file looks like this:

#define MYOPTION1 101

#define MYOPTION2 102

You can then refer to controls in this way:

BOOL FAR PASCAL FirstDlgProc(hDlg, wMessage, wParam, lParam)

.

.

.

switch (WM_COMMAND)

{

case IDOK :

/* Respond to Ok button here */

break;

case IDCANCEL :

/* Respond to Cancel button here */

break;

case MYOPTION1:

/* Respond to MyOption1 button here */

break;

case MYOPTION2:

/* Respond to MyOption2 button here */

break;

.

.

.

Remember that IDOK and IDCANCEL are predefined by Windows, and should be used for the OK and Cancel buttons in your dialog box.

Modifying a Dialog

Since they are text files, you may be tempted to modify the .DLG file and the .H file directly. However, the two are interdependent, and if you make a change to one file, you risk creating a conflict with the other. Also, changes you make in the .DLG file won't become a permanent part of a dialog because the .DLG file is only written by the editor, not read. The best way to modify a dialog is to load it into the editor and make the changes there.