Click here to Skip to main content
15,895,781 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.9K   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.
/**
 * \file PropPageCtl.cpp
 *
 * \brief Implementation file for class CPropPageCtl
 *
 * $Id: PropPageCtl.cpp, v1.1.1.1 2006/09/24 23:12:30 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 //
////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"             // Pre-compiled header
#include "IncVersion.h"			// MIDL-generated bindings
#include "AddIn.h"              // Project header
#include "PropPageCtl.h"        // For class CPropPageCtl

////////////////////////////////////////////////////////////////////////
// Class CPropPageCtl

CPropPageCtl::CPropPageCtl()
{
	m_bWindowOnly = TRUE;
	CalcExtent(m_sizeExtent);

	m_dwDigit = DEF_DIGIT;
	m_bResetLowerVersions = DEF_RESET;
	m_bRevertToBuildNumber = DEF_REVERT;
}

HRESULT CPropPageCtl::FinalConstruct()
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::FinalConstruct\n"));
	return S_OK;
}

void CPropPageCtl::FinalRelease()
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::FinalRelease\n"));
}

////////////////////////////////////////////////////////////////////////
// Interface IDTToolsOptionsPage

/**
 * \brief Occurs immediately after a custom Tools Options page is
 * created for the first time
 *
 *
 * \param pDTEObject The parent object of the Tools Options page,
 * namely, a DTE object
 *
 * \return This method always returns S_OK
 *
 *
 * After OnAfterCreated occurs, the custom Tools Options page is ready
 * to accept user input.
 *
 *
 */

STDMETHODIMP CPropPageCtl::OnAfterCreated(EnvDTE::_DTE * /*pDTEObject*/)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnAfterCreated\n"));
	return S_OK;
}

/**
 * \brief Returns an object containing all properties contained on the
 * specified custom Tools Options page.
 *
 *
 * \param pProperties The Tools Options object
 *
 *
 * When you call DTE.Properties("Root", "Page") and "Root" and "Page"
 * correspond to this control, then GetProperties is invoked and the
 * control creates a Properties collection. GetProperties can return
 * NULL if you do not want to implement properties, but it is to your
 * advantage that you do implement properties.
 *
 *
 */

STDMETHODIMP CPropPageCtl::GetProperties(/*[in, out]*/ IDispatch **pProperties)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::GetProperties\n"));

	*pProperties = NULL;

	return S_OK;
}

STDMETHODIMP CPropPageCtl::OnOK()
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnOK\n"));

	CDlgMixin<CPropPageCtl>::OnClickedOK();
	setOptionsToReg(m_dwDigit, m_bResetLowerVersions, m_bRevertToBuildNumber);
	return S_OK;
}

STDMETHODIMP CPropPageCtl::OnCancel()
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnCancel\n"));
	return S_OK;
}

STDMETHODIMP CPropPageCtl::OnHelp()
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnHelp\n"));
	return S_OK;
}

////////////////////////////////////////////////////////////////////////

STDMETHODIMP CPropPageCtl::OnAmbientPropertyChange(DISPID dispid)
{
	if (dispid == DISPID_AMBIENT_BACKCOLOR)
	{
		SetBackgroundColorFromAmbient();
		FireViewChange();
	}

	return IOleControlImpl<CPropPageCtl>::OnAmbientPropertyChange(dispid);
}


////////////////////////////////////////////////////////////////////////

LRESULT CPropPageCtl::OnInitDialog(UINT /*nMsg*/,
								   WPARAM wParam,
								   LPARAM lParam,
								   BOOL &bHandled)
{
	getOptionsFromReg(m_dwDigit, m_bResetLowerVersions, m_bRevertToBuildNumber);

	CDlgMixin<CPropPageCtl>::OnInitDialog(wParam, lParam, bHandled);

	return 0L;
}

STDMETHODIMP CPropPageCtl::OnClickedVersion(WORD /*wNotifyCode*/,
											WORD /*wID*/,
											HWND /*hWndCtl*/,
											BOOL& /*bHandled*/)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnClickedVersion\n"));
	return HRESULT(CDlgMixin<CPropPageCtl>::OnClickedVersion());
}

STDMETHODIMP CPropPageCtl::OnClickedStatusMajorVersion(WORD /*wNotifyCode*/,
													   WORD /*wID*/,
													   HWND /*hWndCtl*/,
													   BOOL& /*bHandled*/)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnClickedStatusMajorVersion\n"));
	return HRESULT(CDlgMixin<CPropPageCtl>::OnClickedStatusMajorVersion());
}

STDMETHODIMP CPropPageCtl::OnClickedStatusMinorVersion(WORD /*wNotifyCode*/,
													   WORD /*wID*/,
													   HWND /*hWndCtl*/,
													   BOOL& /*bHandled*/)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnClickedStatusMinorVersion\n"));
	return HRESULT(CDlgMixin<CPropPageCtl>::OnClickedStatusMinorVersion());
}

STDMETHODIMP CPropPageCtl::OnClickedStatusRevision(WORD /*wNotifyCode*/,
												   WORD /*wID*/,
												   HWND /*hWndCtl*/,
												   BOOL& /*bHandled*/)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnClickedStatusRevision\n"));
	return HRESULT(CDlgMixin<CPropPageCtl>::OnClickedStatusRevision());
}

STDMETHODIMP CPropPageCtl::OnClickedStatusBuildNumber(WORD /*wNotifyCode*/,
													  WORD /*wID*/,
													  HWND /*hWndCtl*/,
													  BOOL& /*bHandled*/)
{
	ATLTRACE2(atlTraceControls, 3, _T("CPropPageCtl::OnClickedStatusBuildNumber\n"));
	return HRESULT(CDlgMixin<CPropPageCtl>::OnClickedStatusBuildNumber());
}

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

// PropPageCtl.cpp ends here.

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