From: RB on
I'm trying to figure the best way to set and track my MFC app version.
The issue is I see that the AppWizard upon project creation puts
version 1.0 in a static text in the class CAboutDlg : public CDialog.
I can manually edit this but it would seem there would be either
a way to access the value from code in MyDoc Class, or at least set
this value from code so that I don't have to manually edit said static text
to match whatever version I am implementing in my code or
schema. Appreciate any input on the best way to do the above or
how you implement your version data.



From: Joseph M. Newcomer on
I consider the Microsoft About box one of the single worst pieces of code generated by the
framework, and it proves once again that software *evolves* (there is no trace of
Intelligent Design anywhere!)

What you have to do is use the version APIs to get the version number of the current
executable (GetModuleFileName), then format it yourself in the OnInitInstance handler of
the About dialog (had there been any trace of Intelligent Design (a) this would have
already been done for you and (b) the About box would be in a separate pair of files
About.cpp and About.h, and we could then write once and replug an intelligently-designed
Abput box in)

The About box is the result of some summer intern being allowed to do design. No one who
cared about software could possibly have come up with a design as bad as the one we have
now for the About box.

You can download the About box code that Brent Rector wrote if you go to
www.flounder.com/downloads and download the code for our book. I did some minor
enhancements, but the code is over ten years old and doesn't cover modern CPUs. I should
rewrite it to use the CPUID instruction instead of the sort-of-kludge it uses. But
Brent's code will nicely substitute values from the VERSIONINFO resource into the static
controls (you preload the static control with the VERSIONINFO keyword you want to use!)

But Brent is an Intelligent Designer. Too bad something this simple couldn't have been
produced by the framework.
joe

On Fri, 11 Jun 2010 23:01:16 -0400, "RB" <NoMail(a)NoSpam> wrote:

>
>I'm trying to figure the best way to set and track my MFC app version.
>The issue is I see that the AppWizard upon project creation puts
>version 1.0 in a static text in the class CAboutDlg : public CDialog.
>I can manually edit this but it would seem there would be either
>a way to access the value from code in MyDoc Class, or at least set
>this value from code so that I don't have to manually edit said static text
>to match whatever version I am implementing in my code or
>schema. Appreciate any input on the best way to do the above or
>how you implement your version data.
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Webber on


"RB" <NoMail(a)NoSpam> wrote in message
news:#dg$MudCLHA.4604(a)TK2MSFTNGP05.phx.gbl...

> I'm trying to figure the best way to set and track my MFC app version.
> The issue is I see that the AppWizard upon project creation puts
> version 1.0 in a static text in the class CAboutDlg : public CDialog.
> I can manually edit this but it would seem there would be either
> a way to access the value from code in MyDoc Class, or at least set
> this value from code so that I don't have to manually edit said static
> text
> to match whatever version I am implementing in my code or
> schema. Appreciate any input on the best way to do the above or
> how you implement your version data.

Let me suggest an alternative to extracting the version number with the
Version APIs as Joe suggests.

I have a couple of EXE's and a few DLL's, and when I build them, I want them
all to get matching version numbers.

So I put the versioninfo in the .rc2 file (to stop appstudio from buggering
it about) and use #defined constants (VERMAJ, VERMIN, VERFIX, BUILDNUMBER)
from an included header file (see below).

This means that I can change the version number of all my modules very
easily, and I can also get the version number by including the header file
in .cpp files.

Dave
--
David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

//==================================

VS_VERSION_INFO VERSIONINFO
FILEVERSION VERMAJ,VERMIN,VERFIX,BUILDNUMBER
PRODUCTVERSION VERMAJ,VERMIN,VERFIX,BUILDNUMBER
.....
VALUE "FileVersion", VERSIONSTRING
VALUE "ProductVersion", PRODUCTSTRING
.....


//==================================
The included header file contains:

// Stringisation.
// (Two steps needed).

#define _STR(x) #x
#define STR(x) _STR(x)

// The following are used as defined quantities
// in the versioninfo resource:

#define VERMAJ 1
#define VERMIN 0
#define VERFIX 0
#define BUILDNUMBER 0

#define VERMAJSTR STR( VERMAJ )
#define VERMINSTR STR( VERMIN )
#define VERFIXSTR STR( VERFIX )
#define BUILDSTR STR( BUILDNUMBER )#define VERSIONSTRING VERMAJSTR "." VERMINSTR "." VERFIXSTR "." BUILDSTR
#define PRODUCTSTRING VERMAJSTR "." VERMINSTR "." VERFIXSTR "." BUILDSTR


//==================================



From: David Wilkinson on
David Webber wrote:
> Let me suggest an alternative to extracting the version number with the
> Version APIs as Joe suggests.
>
> I have a couple of EXE's and a few DLL's, and when I build them, I want
> them all to get matching version numbers.
>
> So I put the versioninfo in the .rc2 file (to stop appstudio from
> buggering it about) and use #defined constants (VERMAJ, VERMIN, VERFIX,
> BUILDNUMBER) from an included header file (see below).

Clever. Why didn't I think of this?

--
David Wilkinson
Visual C++ MVP
From: RB on
Thanks Joe.