Click here to Skip to main content
15,880,725 members
Articles / Desktop Programming / MFC

Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET

Rate me:
Please Sign up or sign in to vote.
4.98/5 (71 votes)
10 Jan 2005CPOL25 min read 529.9K   12.1K   201  
An application/add-in to organise and renumber resource symbol IDs
/************************************************************************
 *
 *            Resource ID Organiser Add-In for Visual C++.NET
 *
 * (c) Copyright 2000-2002 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResOrgNETAddInToolWindowsCtrl.cpp
 *
 *  Description : CResOrgNETAddInToolWindowsCtrl - ResOrg.NET Tool Window
 *                ActiveX control class
 *
 *  Compiler    : Microsoft Visual C++ .NET
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 2000/XP
 *
 *  NOTE:
 *
 *    This software is provided "as is" free for personal use. All
 *    title and copyrights in and to the software, including but not
 *    limited to any images, text, etc. incorporated into it, are
 *    owned by Anna-Jayne Metcalfe, except where acknowledged otherwise.
 *
 *    Your may freely to use this code in your own products, PROVIDED
 *    this notice is not removed or modified.
 *
 *
 *    Visit http://www.annasplace.me.uk/resorg for latest updates
 *
 ************************************************************************
 *
 *   MODIFICATION HISTORY:
 *
 *           This is a controlled document. See project configuration
 *           control tool for latest version and full version history.
 *
 *    $Archive: /Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows/ResOrgNETAddInToolWindowsCtrl.cpp $
 *   $Revision: 7 $
 *       $Date: 25/11/02 16:50 $
 *     $Author: Anna $
 *
 *    $History: ResOrgNETAddInToolWindowsCtrl.cpp $
 * 
 * *****************  Version 7  *****************
 * User: Anna         Date: 25/11/02   Time: 16:50
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows
 * Changed website address in banner
 * 
 * *****************  Version 6  *****************
 * User: Anna         Date: 22/10/02   Time: 14:45
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows
 * Changed name/email address (at last!)
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 8/08/02    Time: 20:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows
 * Added CResOrgNETAddInToolWindowsCtrl::PreTranslateMessage() in a vaind
 * attempt to find out why the tooltips aren't showing in the Form View
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 6/08/02    Time: 10:34
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows
 * Removed PROPPAGEIDS macros (this control has no property pages)
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 5/08/02    Time: 13:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows
 * This control now has no property pages...remember to tell the framework
 * that!
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 2/08/02    Time: 17:04
 * Updated in $/Projects/AddIns/ResOrg/ResOrgNETAddInToolWindows
 * 1.  Added file banners
 * 2.  Tidied up the code a little - removing unused capabilities
 * 
 * $Nokeywords: $
 *
 ************************************************************************/

// ResOrgNETAddInToolWindowsCtrl.cpp : Implementation of the CResOrgNETAddInToolWindowsCtrl ActiveX Control class.

#include "StdAfx.h"
#include "ResOrgNETAddInToolWindows.h"
#include "ResOrgNETAddInToolWindowsCtrl.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl class

IMPLEMENT_DYNCREATE(CResOrgNETAddInToolWindowsCtrl, CResOrgNETAddInToolWindowsCtrl_BASE)


// Message map
BEGIN_MESSAGE_MAP(CResOrgNETAddInToolWindowsCtrl, CResOrgNETAddInToolWindowsCtrl_BASE)

	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
	ON_WM_CREATE()
	ON_WM_SIZE()

END_MESSAGE_MAP()


// Dispatch map
BEGIN_DISPATCH_MAP(CResOrgNETAddInToolWindowsCtrl,		CResOrgNETAddInToolWindowsCtrl_BASE)

	DISP_FUNCTION_ID(CResOrgNETAddInToolWindowsCtrl,	"Initialise",	1,	Initialise,	VT_BOOL,	VTS_DISPATCH VTS_UI4)
	DISP_FUNCTION_ID(CResOrgNETAddInToolWindowsCtrl,	"Refresh",		2,	Refresh,	VT_EMPTY,	VTS_NONE)

END_DISPATCH_MAP()


// Event map
BEGIN_EVENT_MAP(CResOrgNETAddInToolWindowsCtrl, CResOrgNETAddInToolWindowsCtrl_BASE)
END_EVENT_MAP()


// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CResOrgNETAddInToolWindowsCtrl, "RESORGNETADDINTO.ResOrgNETAddInToCtrl.1",
	0x7cfd71d, 0x3aea, 0x47db, 0x8f, 0x7b, 0xd4, 0x27, 0xa8, 0xcb, 0x8a, 0xaf)


// Type library ID and version
IMPLEMENT_OLETYPELIB(CResOrgNETAddInToolWindowsCtrl, _tlid, _wVerMajor, _wVerMinor)


// Interface IDs
const IID BASED_CODE IID_DResOrgNETAddInToolWindows =
		{ 0x7542A9D7, 0x23A4, 0x4ADD, { 0xBD, 0x8B, 0x9B, 0xF7, 0x6B, 0xBD, 0x82, 0xD6 } };

const IID BASED_CODE IID_DResOrgNETAddInToolWindowsEvents =
		{ 0x25FE1BE9, 0x9A00, 0x4259, { 0xAA, 0x6D, 0x84, 0xF1, 0xDC, 0xF0, 0x49, 0x13 } };


// Control type information
static const DWORD BASED_CODE _dwResOrgNETAddInToolWindowsOleMisc =
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST |
	OLEMISC_INSIDEOUT |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(	CResOrgNETAddInToolWindowsCtrl,
						IDS_TOOLWIN,
						_dwResOrgNETAddInToolWindowsOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl construction/destruction

CResOrgNETAddInToolWindowsCtrl::CResOrgNETAddInToolWindowsCtrl(void)
{
	InitializeIIDs( &IID_DResOrgNETAddInToolWindows,
					&IID_DResOrgNETAddInToolWindowsEvents);

	m_hWndResOrg	= NULL;
}


CResOrgNETAddInToolWindowsCtrl::~CResOrgNETAddInToolWindowsCtrl(void)
{
}



/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl virtual overrides

BOOL CResOrgNETAddInToolWindowsCtrl::PreTranslateMessage(MSG* pMsg)
{
	return CResOrgNETAddInToolWindowsCtrl_BASE::PreTranslateMessage(pMsg);
}


// CResOrgNETAddInToolWindowsCtrl::OnDraw - Drawing function
void CResOrgNETAddInToolWindowsCtrl::OnDraw(CDC* pDC,
											const CRect& rcBounds,
											const CRect& rcInvalid)
{
	UNREFERENCED_PARAMETER(pDC);
	UNREFERENCED_PARAMETER(rcBounds);
	UNREFERENCED_PARAMETER(rcInvalid);
}


// CResOrgNETAddInToolWindowsCtrl::DoPropExchange - Persistence support
void CResOrgNETAddInToolWindowsCtrl::DoPropExchange(CPropExchange* pPX)
{
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	CResOrgNETAddInToolWindowsCtrl_BASE::DoPropExchange(pPX);

	// TODO: Call PX_ functions for each persistent custom property.
}


// Reset control to a default state
void CResOrgNETAddInToolWindowsCtrl::OnResetState(void)
{
	CResOrgNETAddInToolWindowsCtrl_BASE::OnResetState();  // Resets defaults found in DoPropExchange

	// TODO: Reset any other control state here.
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl operations
// (none)


/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl IDispatch Interface Handlers

BOOL CResOrgNETAddInToolWindowsCtrl::Initialise(LPDISPATCH pApplication,
												unsigned long ulHWND)
{
	m_hWndResOrg = (HWND)ulHWND;

	ASSERT(::IsWindow(m_hWndResOrg) );

	if (m_pDTE == NULL)
	{
		pApplication->QueryInterface(__uuidof(EnvDTE::_DTE), (LPVOID*)&m_pDTE);

		return (m_pDTE != NULL);
	}
	return FALSE;
}


void CResOrgNETAddInToolWindowsCtrl::Refresh(void)
{
	m_ctrlMain.Refresh();
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl implementation

// Adds or removes system registry entries for CResOrgNETAddInToolWindowsCtrl
BOOL CResOrgNETAddInToolWindowsCtrl::CResOrgNETAddInToolWindowsCtrlFactory::UpdateRegistry(BOOL bRegister)
{
	// TODO: Verify that your control follows apartment-model threading rules.
	// Refer to MFC TechNote 64 for more information.
	// If your control does not conform to the apartment-model rules, then
	// you must modify the code below, changing the 6th parameter from
	// afxRegApartmentThreading to 0.

	if (bRegister)
	{
		return ::AfxOleRegisterControlClass(::AfxGetInstanceHandle(),
											m_clsid,
											m_lpszProgID,
											IDS_TOOLWIN,
											IDB_TOOLWIN,
											afxRegApartmentThreading,
											_dwResOrgNETAddInToolWindowsOleMisc,
											_tlid,
											_wVerMajor,
											_wVerMinor);
	}
	else
	{
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
	}
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgNETAddInToolWindowsCtrl message handlers

int CResOrgNETAddInToolWindowsCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CResOrgNETAddInToolWindowsCtrl_BASE::OnCreate(lpCreateStruct) == -1)
		return -1;

	CRect rectCtrl;
	GetClientRect(rectCtrl);

	DWORD dwStyle = WS_VISIBLE | WS_CHILD; //| LVS_REPORT;

	m_ctrlMain.Create(	NULL,
						_T("Main"),
						dwStyle,
						rectCtrl,
						this,
						0,
						NULL);

	ASSERT(m_pDTE != NULL);

	if (m_ctrlMain.Initialise(m_pDTE, m_hWndResOrg) )
	{
		m_ctrlMain.Refresh();
	}
	return 0;
}


void CResOrgNETAddInToolWindowsCtrl::OnSize(UINT nType, int cx, int cy)
{
	CResOrgNETAddInToolWindowsCtrl_BASE::OnSize(nType, cx, cy);

	CRect rectCtrl;
	GetClientRect(rectCtrl);

	m_ctrlMain.MoveWindow(rectCtrl);
}

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
Founder Riverblade Limited
United Kingdom United Kingdom
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing Darth Vader's Codpiece * for the UK Army in 1990).
    * Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company, Riverblade Ltd.

One of my personal specialities is IDE plug-in development. ResOrg was my first attempt at a plug-in, but my day to day work is with Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.

I love lots of things, but particularly music, photography and anything connected with history or engineering. I despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...Laugh | :laugh:

I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!

Comments and Discussions