Click here to Skip to main content
15,860,972 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 527.5K   12.1K   201  
An application/add-in to organise and renumber resource symbol IDs
// NGMDIFrameWnd.cpp : implementation of the CNGMDIFrameWnd class
//

#include "stdafx.h"

#include "NGUtils.h"
#include "NGMDIFrameWnd.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif



/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd

IMPLEMENT_DYNCREATE(CNGMDIFrameWnd, CNGMDIFrameWnd_BASE)

BEGIN_MESSAGE_MAP(CNGMDIFrameWnd, CNGMDIFrameWnd_BASE)
	//{{AFX_MSG_MAP(CNGMDIFrameWnd)
	ON_WM_CREATE()
	ON_WM_SHOWWINDOW()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};


/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd construction/destruction

CNGMDIFrameWnd::CNGMDIFrameWnd(void)
{
	m_sCtrlBarProfileName	= _T("");
	m_bInitialShow			= FALSE;
}


CNGMDIFrameWnd::~CNGMDIFrameWnd(void)
{
}


/******************************************************************************
 *	Called by the framework before the window is created
 *
 ******************************************************************************/

BOOL CNGMDIFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CNGMDIFrameWnd_BASE::PreCreateWindow(cs);
}


/******************************************************************************
 *	Called by the framework when the window is created
 *
 ******************************************************************************/

int CNGMDIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	int nResult = CNGMDIFrameWnd_BASE::OnCreate(lpCreateStruct);
	if (nResult != -1)
	{
	}
	return nResult;
}



	
/******************************************************************************
 *	Called by the app to show the main window
 *
 ******************************************************************************/

void CNGMDIFrameWnd::InitialShowWindow(UINT nCmdShow)
{
	m_bInitialShow = true;

	if (!m_sCtrlBarProfileName.IsEmpty())
	{
		LoadBarState(m_sCtrlBarProfileName);
	}
	WINDOWPLACEMENT wp;
	if (!::ReadWindowPlacement(&wp))
	{
		ShowWindow(nCmdShow);
		return;
	}
	if (nCmdShow != SW_SHOWNORMAL)
	{
		wp.showCmd = nCmdShow;
	}
	SetWindowPlacement(&wp);

	CMDIChildWnd* pChild = MDIGetActive();
	if (NULL != pChild)
	{
		MDIMaximize(pChild);
	}
}


/******************************************************************************
 *	Called by the framework when a child window is created
 *
 ******************************************************************************/

BOOL CNGMDIFrameWnd::OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
	BOOL bResult = CNGMDIFrameWnd_BASE::OnCreateClient(lpcs, pContext);

	return bResult;
}


/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd operations

/******************************************************************************
 *	Opens a new view on the given document
 *
 *	The view type depends on the given document template
 *
 ******************************************************************************/

void CNGMDIFrameWnd::CreateView(CDocument* pDoc, CDocTemplate* pTemplate)
{
	ASSERT_VALID(pTemplate);

	if (NULL == pDoc)
	{
		TRACE0("Warning: No active document for WindowNew command.\n");
		AfxMessageBox(AFX_IDP_COMMAND_FAILURE, MB_OK | MB_ICONSTOP);
		return;     // command failed
	}

	CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDoc, NULL);
	if (pFrame == NULL)
	{
		TRACE0("Warning: failed to create new frame.\n");
		AfxMessageBox(AFX_IDP_COMMAND_FAILURE, MB_OK | MB_ICONSTOP);
		return;     // command failed
	}
	pTemplate->InitialUpdateFrame(pFrame, pDoc);
}


/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd diagnostics

#ifdef _DEBUG
void CNGMDIFrameWnd::AssertValid(void) const
{
	CNGMDIFrameWnd_BASE::AssertValid();
}


void CNGMDIFrameWnd::Dump(CDumpContext& dc) const
{
	CNGMDIFrameWnd_BASE::Dump(dc);
}

#endif //_DEBUG



/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd message handlers

/******************************************************************************
 *	The framework calls this member function when the window
 *	is shown or hidden.
 *
 *	This override determines if the window is being shown for the first time,
 *	and, if so, calls InitialShowWindow() to load the window size/position
 *	from the registry.
 *
 ******************************************************************************/

void CNGMDIFrameWnd::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CNGMDIFrameWnd_BASE::OnShowWindow(bShow, nStatus);
	
	if (bShow && (nStatus == 0) && !m_bInitialShow)
	{
		InitialShowWindow(SW_SHOWNORMAL);
	}
}


/******************************************************************************
 *	The framework calls this member function as a signal that the window
 *	should be closed
 *
 *	This override saves the state of all docking windows, and the 
 *	size/position of the main window before exiting
 *
 ******************************************************************************/

void CNGMDIFrameWnd::OnClose(void)
{
	ASSERT(::IsWindow(m_hWnd));

	if (!m_sCtrlBarProfileName.IsEmpty())
	{
		SaveBarState(m_sCtrlBarProfileName);
	}

	// Before it is destroyed, save the position of the window
	WINDOWPLACEMENT wp;
	wp.length = sizeof wp;
	if (GetWindowPlacement(&wp))
	{
		wp.flags = 0;
		if (IsZoomed())
		{
			wp.flags |= WPF_RESTORETOMAXIMIZED;
		}
		// ...and write it to the registry
		::WriteWindowPlacement(&wp);
	}
	CNGMDIFrameWnd_BASE::OnClose();
}


/////////////////////////////////////////////////////////////////////////////
// CNGMDIFrameWnd implementation

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