Introduction
Not a long time ago I wrote a backup tool for my personal use and I wanted to have a WinZip-like Extract File dialog. I was looking for some solutions in the Internet, but did not find anything suitable for me. So, I decided to write it myself and I want to share this code as it seems to me it may be useful. The first thing that I understood was that it is not very simple to work with the Windows Shell, so I was looking for solutions on CodeProject. I found an excellent MFC CShellTreeCtrl
example by Paolo Messina, so I ported it to WTL, and it is the base of my dialog. I used VC 7.1. This code could not be compiled on VC 6.0, as Till Krullmann's Dialog Layout library requires ATL 7.0 collection classes.
Credits
I'd like to thank Paolo Messina for his CShellTreeCtrl
, without it my work would be much complicated, and Till Krullmann for his amazing Dialog Layout library, that is used for dialog resizing. I apologize that I can not personally thank all people whose code I have used in the CVxButton
class, as I wrote it almost four years ago, in order to give an XP look to my application, but most of it I found in CodeProject.
Using the code
To use the code in the application, copy folders "WaitTree", "DialogLayout" and "Mtl" to your project folder and add all of the files from these folders to the project. Copy and add files "ExtractDialog.h" and "ExtractDialog.cpp" to the project, and include "ExtractDialog.h". Be sure that files "atlcoll.h", "atlstr.h" and "atlmisc.h" are included. Define _WTL_NO_CSTRING
before including "atlmisc.h". Declare CExtractDialog
variable wherever you want - and that's all: call the DoModal
function, and you will see the dialog. After the dialog is closed, all selected settings could be retrieved.
#include "ExtractDialog.h"
BOOL foo(LPCTSTR pszInitialFolder = _T(""))
{
CExtractDialog dlg;
dlg.SetFolderName(pszInitialFolder);
if(dlg.DoModal() == IDOK)
{
CString strWildCard;
CString strFolder = dlg.GetFolderName();
if(dlg.GetUseSelected())
strWildCard = dlg.GetFilesMask();
return TRUE;
}
return FALSE;
}
Disclaimer
THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO RESPONSIBILITIES FOR POSSIBLE DAMAGES CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE RISK OF USING THIS SOFTWARE.
History
- Version 1.0 - first release.
Just to say Good-Bye
Sorry for my English :)