Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / ATL

Increment File and Product Version Number - Multiple IDE

Rate me:
Please Sign up or sign in to vote.
4.58/5 (32 votes)
21 Oct 2008CPOL12 min read 293.2K   1.2K   134  
An add-in to automatically increment the FileVersion and ProductVersion fields in your application's resource file. Works in VC6 and VS2005, and probably all versions in between.
#ifndef CONFIGDLG_H_B900CA7A_8C0A_4665_B5B7_AD9DAC923757
#define CONFIGDLG_H_B900CA7A_8C0A_4665_B5B7_AD9DAC923757
/**
 * \file DlgMixin.h
 *
 * \brief Header file for template class CDlgMixin
 *
 * $Id: DlgMixin.h, v1.1.1.1 2006/09/24 23:12:29 mgh Exp $
 *
 *
 * Copyright (C) 2006 Michael G. Herstine <sp1ff@pobox.com>
 *
 * Permission to use, copy, or modify this source code is hereby granted
 * free of charge, provided that this copyright notice appear on all
 * copies and on all source code derived from this code.  No
 * representation is made regarding the suitability of this software for
 * any purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 *
 */

////////////////////////////////////////////////////////////////////////////
// Modified by Jordan Walters, 01.03.2008 for multi-IDE version increment //
////////////////////////////////////////////////////////////////////////////

#ifndef DLGMIXIN_H_9C889376_DB3D_465B_8B7A_E4F0D0DAF90F
#include "DlgMixin.h"          // For base class CDlgMixin
#endif // not "DlgMixin.h"

#ifndef RESOURCE_H_INCLUDED
#include "Resource.h"          // Resource definitions
#define RESOURCE_H_INCLUDED
#endif // not "Resource.h"

/**
 * \class CConfigDlg
 *
 * \brief Dialog class for AddIns that can't integrate into their host's
 * property sheet
 *
 * \sa CDlgMixin, CPropPageCtl
 *
 *
 * Some of the applications that may host this AddIn permit us to
 * integrate one or more property pages into their Tools | Options
 * property sheets, others do not.  For those that do not, we implement
 * our own configuration dialog box.
 *
 * Note that we subclass CDlgMixin to pick up implementation code common
 * to both this, our stand-alone dialog implementation, and
 * CPropPageCtl, our composite control.
 *
 *
 */

class CConfigDlg:
	public CDlgMixin<CConfigDlg>,
	public CDialogImpl<CConfigDlg>
{
public:
	/// Resource ID -- name required by CDialogImpl
	static const UINT IDD = IDD_CONFIG;

public:
	/// Construct with the current digit
	CConfigDlg();
	~CConfigDlg();
	/// Used by CDlgMixin
	DWORD getDigit() const
	{ return m_dwDigit; }
	bool getResetLowerVersions() const
	{ return m_bResetLowerVersions; }
	bool getRevertToBuildNumber() const
	{ return m_bRevertToBuildNumber; }
	/// Used by CDlgMixin
	void setDigit(const DWORD dwDigit)
	{ m_dwDigit = dwDigit; }
	void setResetLowerVersions(const bool bResetLowerVersions)
	{ m_bResetLowerVersions = bResetLowerVersions; }
	void setRevertToBuildNumber(const bool bRevertToBuildNumber)
	{ m_bRevertToBuildNumber = bRevertToBuildNumber; }

#ifndef DOXYGEN_INVOKED        // Shield the macros from doxygen...
	BEGIN_MSG_MAP(CConfigDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK)
		COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel)
		COMMAND_HANDLER(IDC_RADIO_MAJ, BN_CLICKED, OnClickedVersion)
		COMMAND_HANDLER(IDC_RADIO_MIN, BN_CLICKED, OnClickedVersion)
		COMMAND_HANDLER(IDC_RADIO_REV, BN_CLICKED, OnClickedVersion)
		COMMAND_HANDLER(IDC_RADIO_BLD, BN_CLICKED, OnClickedVersion)
		COMMAND_HANDLER(IDC_STATIC_MAJ, BN_CLICKED, OnClickedStatusMajorVersion)
		COMMAND_HANDLER(IDC_STATIC_MIN, BN_CLICKED, OnClickedStatusMinorVersion)
		COMMAND_HANDLER(IDC_STATIC_REV, BN_CLICKED, OnClickedStatusRevision)
		COMMAND_HANDLER(IDC_STATIC_BLD, BN_CLICKED, OnClickedStatusBuildNumber)
		CHAIN_MSG_MAP(CDlgMixin<CConfigDlg>)
	END_MSG_MAP()
#endif // not DOXYGEN_INVOKED

public:
	/// WM_INITDIALOG handler
	LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
	/// BN_CLICKED handler for IDOK
	LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	/// BN_CLICKED handler for IDCANCEL
	LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	/// BN_CLICKED handler for IDC_RADIO_MAJ, IDC_RADIO_MIN, IDC_RADIO_REV or IDC_RADIO_BLD
	LRESULT OnClickedVersion(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	/// BN_CLICKED handlers for IDC_STATIC_MAJ, IDC_STATIC_MIN, IDC_STATIC_REV or IDC_STATIC_BLD
	LRESULT OnClickedStatusMajorVersion(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnClickedStatusMinorVersion(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnClickedStatusRevision(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
	LRESULT OnClickedStatusBuildNumber(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);

private:
	/// Temporary store for the choice of version digit to increment
	// -- written to Registry on IDOK
	DWORD m_dwDigit;
	bool m_bResetLowerVersions;
	bool m_bRevertToBuildNumber;

}; // End class CConfigDlg.

// Local Variables:
// fill-column: 72
// indent-tabs-mode: nil
// show-trailing-whitespace: t
// End:

#endif // CONFIGDLG_H_B900CA7A_8C0A_4665_B5B7_AD9DAC923757

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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)
United Kingdom United Kingdom
Ok, it's about time I updated this profile. I still live near 'Beastly' Eastleigh in Hampshire, England. However I have recently been granted a permamant migration visa to Australia - so if you're a potential employer from down under and like the look of me, please get in touch.
Still married - just, still with just a son and daughter. But they are now 8 and 7 resp and when together they have the energy of a nuclear bomb.
I worked at Teleca UK for over 8.5 years (but have now moved to TikitTFB) and have done loads of different things. Heavily involved with MFC, SQL, C#, The latest is ASP.NET with C# and Javascript. Moving away from Trolltech Qt3 and 4.
Jordan.

Comments and Discussions