Click here to Skip to main content
15,881,757 members
Articles / Desktop Programming / MFC
Article

XFileProperties - A modeless dialog to display file properties

Rate me:
Please Sign up or sign in to vote.
4.73/5 (13 votes)
13 Jun 2003CPOL3 min read 69.2K   1.2K   31   5
XFileProperties demonstrates the use of CXFileProperties, a class that displays a modeless dialog similar to the Windows file properties dialog.

Introduction

One day my Product Manager asked me to add version information display to our program suite. He asked me how long it would take, and since I knew the trick for displaying the Windows properties dialog, I told him it would take two days. Big mistake! I forgot that he almost never likes first thing I show him. So, next day, I showed him this:

XFileProperties screenshot

And naturally he did not like it. He was concerned that users may click on Advanced button and change something, which would cause us support problems. OK, that is not unreasonable. So I toldl him that we would need to reverse engineer functionality and create a dialog without user interaction buttons. He asked me how long it would take, and since I knew there were classes available to get version information, I told him it would take four days. Big mistake! I find out that classes available are good if you know version strings in advance (like Product Name, etc.), but not so good if you need to populate two listboxes like in properties dialog. Since some of our apps are actually provided by third-party vendors, we have no control over what version string names they use. I also discovered that at least one vendor has an exe with a custom-generated version resource which seemed to defy all classes I tested it with.

OK, now is time to get serious. After looking through hex dumps of version data, I figured out the structure and how to populate controls, and make dialog look pretty close to Windows properties dialog. Here is test app, which allows you to compare Windows dialog and XFileProperties dialog (both are modeless, and will allow multiple copies of dialog, as long as selected file is different):

XFileProperties screenshot

Clicking on Windows Properties button will display dialog you see above. Clicking on XFileProperties button will display this dialog:

XFileProperties screenshot

The version tab:

XFileProperties screenshot

How to use

To integrate CXFileProperties into your app, you first need to add following files to your project:

  • Version.cpp
  • Version.h
  • XFileProperties.cpp
  • XFileProperties.h
  • XFileProperties.rc
  • XFilePropertiesRes.h
  • XSplitpath.h

Next, include XFileProperties.h in appropriate project files, and include XFileProperties.rc and XFilePropertiesRes.h in your project's rc file. You can do this by going to View | Resource Includes and entering the files as shown below:

XFileProperties screenshot

Now you are ready to start using CXFileProperties. Here is code that invokes CXFileProperties in demo app:

void CFilePropertiesTestDlg::OnXfileprops()
{
    CString str;
    m_FileName.GetWindowText(str);

    CXFileProperties *pDlg = new CXFileProperties(str, this);

    if (!pDlg)
    {
        ASSERT(FALSE);
    }
}

Acknowledgments

Revision History

Version 1.0 - 2003 June 14

  • Initial public release.

Usage

This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Hans Dietrich Software
United States United States
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.

Recently, I have moved to Los Angeles where I am doing consulting and development work.

For consulting and custom software development, please see www.hdsoft.org.






Comments and Discussions

 
QuestionHelp on XFileProperties Pin
Honeyz Smiles18-Oct-05 21:34
Honeyz Smiles18-Oct-05 21:34 
GeneralThe trick for displaying the Windows properties dialog Pin
pryhoda25-Aug-04 6:34
pryhoda25-Aug-04 6:34 
GeneralRe: The trick for displaying the Windows properties dialog Pin
pryhoda25-Aug-04 6:35
pryhoda25-Aug-04 6:35 
GeneralFileOwner and Authority Pin
hb.sapto nugroho31-Mar-04 18:57
hb.sapto nugroho31-Mar-04 18:57 
Generalwindows properties dialog position Pin
artur_v29-Feb-04 21:08
artur_v29-Feb-04 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.