Click here to Skip to main content
Click here to Skip to main content

XFileProperties - A modeless dialog to display file properties

By , 13 Jun 2003
 

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)

About the Author

Hans Dietrich
Software Developer (Senior) Hans Dietrich Software
United States United States
Member
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.






Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionHelp on XFilePropertiesmemberHoneyz Smiles18 Oct '05 - 21:34 
Hi Hans,
 
I am very fortunate that I landed to this website & finally got the answer to my problem- your XFileProperties. I find your article very useful.
 
However, I found out that your variable declarations were declared in the .cpp file (e.g., variable declarations were declared in the XFileProperties.cpp). I placed my variable declarations on the .h file itself.
 
I incorporated your codes on my project & it turned out that when clicking the XFileProperties button, the dialog box (w/ the Property Pages) does not come out/pop out. How come?

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 14 Jun 2003
Article Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid