Using the FileOpenDialogBox class

The FileOpen dialog box is one of the more difficult LHAPI classes to use, since it involves a window that has a complex interation with other windows. This section will try to explain how to use a FileOpenDialogBox. For a concrete example, see the file FILEDLGS.C provided with the ISV disk.

FileOpenDialogBox requires that the control windows in its window array start with these six windows: Edit, PathText, FileListBox,DirListBox,Ok PushButton, Cancel PushButton. There may be more than these windows, but there must be at least these six. The FileOpenDialogBox coordinates with the Edit, PathText, FileListBox and the DirListBox via NOTIFY messages. The children have the STYLE_NOTIFY bit set so that they will send NOTIFY_CHILDCHANGED messages to the F.O.D.B. The DialogBox will then change directories in the FileListBox and the DirListBox by sending them NOTIFY, NOTIFY_UPDATE messages with the Extra field set to the new directory path.

Various information about the status of the file operation is scattered throughout the controls in the file dialog array. In some cases, the Menu field of a control is usurped to function specially for FileOpenDialog.

The example in FILEDLGS has subclassed the FileOpenDialogBox handler. This is to make sure that the two ways to acknowledge the dialog, either by pressing F10 or by pressing Enter, both perform some post-processing on the filename to add a default extension if necessary.