This sample application shows how to build and use a modal dialog box to support the Open command in the File menu. Figure 21.1 shows the dialog box that the FileOpen application displays when the user chooses the Open command:
The dialog box contains the following controls:
A default push-button control labeled Open that lets the user tell the application to open the selected file.
A button control labeled Cancel that lets the user cancel the Open command.
A single-line edit control in which the user can enter the name of the file to open.
A list box containing the names of files in the current directory from which the user can select the file to be opened.
The list box also contains directory and drive names that the user can select to change the current directory or drive.
Several static text controls that label the list box and edit control, and display the current directory name.
To create the FileOpen application, copy and rename the source files for the EditCntl application, then make the following modifications:
1.Add new constants to the include file.
2.Create the Open dialog-box template and add it to the resource script file.
3.Add new variables.
4.Add an IDM_OPEN case to the WM_COMMAND case.
5.Create the OpenDlg dialog function.
6.Add helper functions to support the OpenDlg dialog function.
7.Export the OpenDlg dialog function.
8.Build and run the application.
NOTE:
Rather than typing the code provided in the following sections, you might find it more convenient to simply examine and build the sample source files found on the sample disks.