March 2, 2021
Hot Topics:

Using the Common Dialog Open/Save Boxes

  • By John Percival
  • Send Email »
  • More Articles »

In almost every application you write you are going to need to allow the user to select a file name. The standard Windows Open/Save dialog box is found in the comdlg32.dll library and can be accessed by two methods. The first involves using an ActiveX control, MS Common Dialog Control, which in turn accesses the DLL, and the second accesses the DLL directly via the API. Both have their advantages and disadvantages. The OCX method requires you to have a form on which to place the control. It also incurs a performance penalty, as the OCX libraries must be loaded on top of the DLL. It does not allow for as much flexibility as the API, but is much easier to use. Almost all of the properties can be set at design-time, meaning that you must only invoke one method to display the dialog. The API requires you to set up a UDT, including string buffers, before you can show the dialog. The advantages of the API easily outweigh this though. There is no need to deploy a hefty OCX (140kb) with your application, as the comdlg32.dll is distributed with Windows. You also have several more options and increased flexibility with the API method.

I will show you how to use each method, and you can decide how easy each method is, and whether the extra flexibility of the DLL is worth the extra code.

Page 1 of 5

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date