|
|
От: |
SchweinDeBurg
|
https://zarezky.spb.ru/ |
| Дата: | 06.12.04 21:40 | ||
| Оценка: | |||
This article describes how to go beyond the normal customization associated with the Windows common file open dialog. The common file open dialog is easily one of the most often customized entity in the Windows world, but given the limited customization options included with it, it usually isn't very intuitive as to how go about customizing it the way you want. This article tells you how to make it look and behave the way you want it to. Readers are reminded that though the following ideas and concepts deal with the common file open dialog, the techniques presented here can easily be applied to any other common dialog as well.
The included source files will allow you to use the Office 2000 and VS.NET style file dialogs in your applications, which will appear on all versions of Windows 95/98/NT/Me, as well as 2000. To use the dialog, simply add the source files to your project and use the standard CFileDialog calling functions to show / manipulate it.
This article will demonstrate how to resize the instance of a subclassed CFileDialog and then add a 'SelectAll' button that will select all files (but not folders) in the currently displayed folder. The article assumes that you already know how to subclass MFC provided classes and deal with the associated issues. We therefore will concentrate on how to resize the dialog and re-layout the controls on it (so that they properly cover the enlarged dialog window area). Then, we will show how to add the button, capture the user clicks on it and select all currently displayed files in response.
Everyone is familiar with the standard 'File Open' and 'File Save' common dialogs. Microsoft has done a great job of providing advanced functionality for these controls. Each of them is essentially a miniature version of Windows Explorer: in addition to presenting a list of files, the user can drag files within the list, create new folders, rename files, drag-n-drop new files into the dialog from outside, and cut, paste or delete files. These operations are all available right in the middle of Opening or Saving the current file.
But what if you don't want to offer the user that much freedom? The common dialogs offer a lot of powerful features, but is there any way of limiting those features?
In one of our company projects we needed a way to limit a common dialog's functionality to providing a strictly read-only view of files in a folder. This article presents the solution we came up with.
I wanted to import images in various formats into my application. These images could have come from a digital camera or from a scanner and don't necessarily have intelligible names. Look at the filename in the sample picture above. It doesn't exactly drip with meaning.
So it was obvious that I needed to show a preview image in the file import dialog. As the user clicks on files in the ListView the preview control updates to show the image. Naturally I turned to CodeProject to see if anyone had already implemented such a beast. If they have I couldn't find it, so I rolled my own.