For example, in Visual Studio there is such a dialog for opening a project with two switches, is there any easy way to do this without writing the whole dialog from scratch?

2 answers 2

Can. For WinAPI, use the checkboxes in the OPENFILENAME structure that override the dialog template (LPCTSTR lpTemplateName field + OFN_ENABLETEMPLATE flag in the Flags field) and add hooks to the message handler (LPOFNHOOKPROC lpfnHook field + OFN_ENABLEHOOK flag in the le box field). However, there are some restrictions for general file selection templates for reading Open / SaveAS records, depending on whether the old style or the new template style is used (the OFN_EXPLORER flag in the Flags field). In one case, you can only add your template to the standard template, and in the other, completely replace it. Note that the identifiers of your additional controls should not match the identifiers of the standard controls.

Details of this can be found in MSDN in the section Customizing Common Dialog Boxes . It also indicates in which files you can see the definition of standard templates used within the ComDlg32 / Common Dialog Box Library.

This method works on systems starting with Windows 2000 / Windows Server 2000 and higher. If we have enough support for Windows Vista / Windows Server 2008 and higher, we write in C ++, not C, then we use the IFileDialogCustomize interface from the Common Item Dialog .

  • Common Dialog Box Library is already outdated. Should not advise her in 2018. - VTT
  • I completely agree. It all depends on the requirements for backward compatibility. If we are writing under Windows Vista / Windows Server 2008 and above, we use the new interface from the Common Item Dialog , if we want to support Windows 2000 / Windows Server 2000 and above, we write using GetOpenFileName from the Common Dialog Box Library - Denys Save

For this is the interface IFileDialogCustomize . This interface is implemented in standard file selection dialogs. Allows you to add buttons, switches, text fields, etc.