Re: VS_VERSION_INFO static ctrl
"JCO" wrote
Yes I got it to work. I had some code in the cpp file that was causing the
link error. I will review what I have done now.. but everything seems
okay and works.
Good I think you will find it convenient. If you work it right you
only have to edit the header file when anything changes and then
the rest updates itself on compile.
Remember to always keep spaces between items and the quotation
marks or you will end up seeing quotations in the output.
See comment below,
===========================================
//--in your version header file
#define _STR(x) #x
#define STR(x) _STR(x)
#define VERMAJ 1
#define VERMIN 0
#define VERFIX 0
#define BUILDNUM 0
#define YR 2010
#define V_MA_STR_LIT STR( VERMAJ )
#define V_MI_STR_LIT STR( VERMIN )
#define V_FX_STR_LIT STR( VERFIX )
#define B_N_STR_LIT STR( BUILDNUM )
#define YR_STR_LIT STR( YR )
// must leave space between items and the quotation marks or you will end up seeing quotations in the output.
#define VERSTR V_MA_STR_LIT "." V_MI_STR_LIT "." V_FX_STR_LIT "." B_N_STR_LIT "\0"
#define CPY_RT_YR_STR_LITERAL "Copyright (C) " YR_STR_LIT
===============================================
//----and reflected in your rc2 file------//
#include "YourVersion.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERMAJ, VERMIN, VERFIX, BUILDNUM
PRODUCTVERSION VERMAJ, VERMIN, VERFIX, BUILDNUM
............
..................
VALUE "FileVersion", VERSTR
................
===============================================
//----and in your About Dialog------//
#include "YourVersion.h"
class CAboutDlg : public CDialog
{
........
private:
void SetVerStr( );
CString m_strVersion, m_strCpyRightYr ;
........
}
void CAboutDlg::SetVerStr( )
{
m_strVersion.Format( _T(" Version %d.%d.%d.%d"), VERMAJ, VERMIN, VERFIX, BUILDNUM );
m_strCpyRightYr = _T(CPY_RT_YR_STR_LITERAL);
}
BOOL CAboutDlg::OnInitDialog( )
{
CDialog::OnInitDialog( );
SetVerStr();
m_CtrlStaticVer.SetWindowText( m_strVersion );
m_CtrlStaticCr.SetWindowText( m_strCpyRightYr );
return TRUE;
}
=====================================
//-----and in your DocClass constructor--//
#include "YourVersion.h"
CFileHandlingDoc::CFileHandlingDoc( )
{ // These are CStrings in a Version Struct
VerData.Ver.Format( _T("Version %d.%d.%d.%d"), VERMAJ, VERMIN, VERFIX, BUILDNUM );
VerData.CpyRt = _T(CPY_RT_YR_STR_LITERAL);
}
//----and in your DocClass serialize function----//
void CFileHandlingDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring( ))
{
............
ar << VerData.Ver << VerData.CpyRt;
............
}
else
{
............
ar >> VerData.Ver >> VerData.CpyRt;
............
}
}