Click here to Skip to main content
11,718,016 members (85,998 online)
Click here to Skip to main content
Add your own
alternative version

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

, 10 Jan 2005 CPOL 356.5K 10.1K 199
An application/add-in to organise and renumber resource symbol IDs
resorg103.zip
ResOrg103.exe
resorg104.zip
ResOrg104.exe
resorgaddinsetup.zip
ResOrgAddInSetup.exe
resorgaddin_executables.zip
ResOrg.exe
BXFileDialog.dll
CJ609Lib.dll
NGLib103.dll
ResOrgAddIn.dll
ResOrgCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
resorgnetaddinsetup.zip
ResOrgNETAddInSetup.msi
resorgnetaddin_executables.zip
ResOrgNETAddInToolWindows.ocx
ResOrgNET.exe
CJ609LibVc7.dll
NGLib103Vc7.dll
ResOrgNETAddIn.dll
ResOrgNETCore.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ReadMe.rtf
Licence.rtf
resorgnet_executables.zip
ResOrgNET_executables
CJ609LibVc7.dll
NGLib103Vc7.dll
QHTMLight.dll
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgNETAddIn.dll
ResOrgNETAddInToolWindows.ocx
ResOrgNETCore.dll
resorg_demo.zip
ResOrg103.exe
resorg_executables.zip
ResOrgAddIn.dll
BXFileDialog.dll
CJ609Lib.dll
ResOrg.exe
ResOrg.cnt
resorg.fts
ResOrg.hlp
ResOrgCore.dll
NGLib103.dll
resorg_src.zip
BXFileDialog
BXFileDialog.dsp
Lib
Release
Res
bitmap2.bmp
FileOpen.bmp
filesave.bmp
CJLibrary
CJLibrary
CJLibrary.def
CJLibrary.dsp
CJLibrary.dsw
CJLibrarydep.jpg
CJLibraryStatic.dsp
Debug_Unicode
Release
Release_Unicode
res
Include
res
btn_arro.bmp
btn_explorer.bmp
button_images.bmp
cj_logo.bmp
dragging.cur
handcur.cur
headerba.bmp
hsplitba.cur
icr_hand.cur
nodraggi.cur
PushPin.bmp
Toolbar.bmp
vsplitba.cur
Lib
default.doxygen
NGLibrary
Bin
NGLibrary.def
NGLibrary.dsp
NGLibrary.dsw
Release
Res
Drives.bmp
Release
ResOrg.dsw
ResOrgAddIn
Release
Res
HtmlDoc.ico
ResOrg.ico
ResOrgDoc.ico
TBarLrge.bmp
TBarMedm.bmp
Toolbar.bmp
WorkspaceTabs.bmp
ResOrgAddIn.def
ResOrgAddIn.dsp
ResOrgAddIn.odl
ResOrgAddIn_Res.hm
ResOrgApp
Lint
Release
Res
HtmlDoc.ico
MAINFRAM.BMP
ResOrg.ico
ResOrgDoc.ico
TBarLrge.bmp
TBarMedm.bmp
Toolbar.bmp
workspace.ico
WorkspaceTabs.bmp
ResOrgApp.dsp
ResOrgApp_Res.hm
ResOrgApp_Res.resorg
ResOrgCore
Lint
Release
Res
Anna.bmp
BuildOptions.ico
ComCtl Version Prompt.rtf
File Reload Warning Ex.rtf
File Reload Warning.rtf
Global Next Symbol Value Warning Prompt.rtf
information.ico
Invalid Symbol Name.rtf
Mailing List Prompt.rtf
Next Symbol Value Warning Prompt.rtf
project context menu.bmp
project.ico
RenumWiz Completion.rtf
Report.ico
ResOrg Logo.bmp
ResOrg Updated.rtf
ResOrg.ico
resource file.ico
riverblade_logo.bmp
solution.ico
Symbol Delete Warning.rtf
Symbol Name Warning.rtf
Symbol Rename Warning.rtf
SymbolFile.ico
Symbols Delete Warning.rtf
sym_binary.ico
sym_bitmap.ico
sym_command.ico
sym_control.ico
sym_dialog.ico
sym_icon.ico
sym_menu.ico
sym_prompt.ico
sym_resource.ico
sym_string.ico
Toolbar.bmp
VcAddIn.ico
VersionCheck.ico
warning.ico
WizardHeader256.bmp
WizardWatermark256.bmp
ResOrgCore.def
ResOrgCore.dsp
ResOrgCore_Res.hm
ResOrgCore_Res.resorg
Xml
ProblemSymbolReportHtml.xsl
SymbolsReportHtml.xsl
ResOrgNETAddIn
AddIn.def
Release
Res
AddIn.rgs
HtmlDoc.ico
ResOrg.ico
ResOrgDoc.ico
Toolbar.bmp
WorkspaceTabs.bmp
ResOrgNETAddInSetup
Banner.jpg
Intro screen.jpg
Licence.rtf
ReadMe.rtf
Release
ResOrg.ico
ResOrgNETAddInSetup.vdproj
ResOrgNETAddInToolWindows
Release
Res
Edit.ico
Properties.ico
Renumber.ico
ResOrgNETAddInToolWindows.ico
ResOrgNETAddInToolWindowsCtrl.bmp
ResOrgNETAddInToolWindows.def
SatelliteDll
Release
res
AboutBoxCmd.bmp
OpenResOrgCmd.bmp
OptionsCmd.bmp
ViewMainToolWinCmd.bmp
/************************************************************************
 *
 *                   Resource ID Organiser Add-In
 *
 * (c) Copyright 2000-2002 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResOrgProjectsView.cpp
 *
 *  Description : CResOrgProjectsView - project workspace list view class
 *
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or later
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT/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/ResOrgAddIn/ResOrgProjectsView.cpp $
 *   $Revision: 21 $
 *       $Date: 26/03/03 14:10 $
 *     $Author: Anna $
 *
 *    $History: ResOrgProjectsView.cpp $
 * 
 * *****************  Version 21  *****************
 * User: Anna         Date: 26/03/03   Time: 14:10
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Added CResOrgSymbolsDocMultiFile::GetDisplayTitle() to choose the title
 * displayed for a multi-file Symbols Display
 * 
 * *****************  Version 20  *****************
 * User: Anna         Date: 4/03/03    Time: 19:45
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Removed a couple of ASSERTs that aren't needed anymore
 * 
 * *****************  Version 19  *****************
 * User: Anna         Date: 28/01/03   Time: 21:46
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Added multi-file Symbol Display support
 * 
 * *****************  Version 18  *****************
 * User: Anna         Date: 17/12/02   Time: 15:36
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 *  CResOrgProjectsView::OnInitialUpdate() now only subclasses the header
 * control if a WinXP theme is not active
 * 
 * *****************  Version 17  *****************
 * User: Anna         Date: 25/11/02   Time: 16:51
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Changed website address in banner
 * 
 * *****************  Version 16  *****************
 * User: Anna         Date: 22/10/02   Time: 13:34
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Changed name/mail address (at last!)
 * 
 * *****************  Version 15  *****************
 * User: Andy         Date: 2/08/02    Time: 17:03
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Renamed CWorkspaceHelper to CVc6AutomationHelper, and moved it to the
 * ResOrgCore module
 * 
 * *****************  Version 14  *****************
 * User: Andy         Date: 10/31/01   Time: 1:21p
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Fixed a daft bug in CResOrgProjectsView::OnUpdate()
 * 
 * *****************  Version 13  *****************
 * User: Andy         Date: 10/22/01   Time: 11:19a
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Added the option to prompt if the "Next Symbol" values are in use
 * 
 * *****************  Version 12  *****************
 * User: Andy         Date: 10/03/01   Time: 12:52p
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Added "Properties" to the context menu
 * 
 * *****************  Version 11  *****************
 * User: Andy         Date: 10/07/01   Time: 9:39
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Fix syntax errors
 * 
 * *****************  Version 10  *****************
 * User: Andy         Date: 8/07/01    Time: 8:41
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * The Projects Display now autosizes the list control when it is resized
 * 
 * *****************  Version 9  *****************
 * User: Andy         Date: 5/05/01    Time: 20:48
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Trap attempts to Renumber symbols in empty resource symbol files from
 * the Workspace Display
 * 
 * *****************  Version 8  *****************
 * User: Andy         Date: 26/04/01   Time: 19:41
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Renamed Resource.h to ResOrgAddIn_Res.h
 * 
 * *****************  Version 7  *****************
 * User: Andy         Date: 23/04/01   Time: 21:23
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * 1.  Added icons to context menu
 * 2.  Set default item on context menu
 * 
 * *****************  Version 6  *****************
 * User: Andy         Date: 5/03/01    Time: 19:05
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * CResOrgProjectsView::OnCmdOpenProject() now displays a message box if a
 * resource symbol file cannot be located in a project instead of
 * ASSERTing
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 2/03/01    Time: 17:50
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * GetSymbolFileName() is now a global function, rather than a member of
 * CWorkspaceHelper
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 17/02/01   Time: 7:08
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * Context menu ID changed
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 29/11/00   Time: 18:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgAddIn
 * 1.  Moved Office2KDlg code to its own DLL
 * 2.  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

// ResOrgProjectsView.cpp : implementation of the CResOrgProjectsView class
//

#include "StdAfx.h"
#include "ResOrgAddIn_Res.h"

#include "ResOrgAddInApp.h"
#include "ResOrgProjectsDoc.h"

#include "ResOrgProjectsView.h"


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


/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView

IMPLEMENT_DYNCREATE(CResOrgProjectsView, CResOrgProjectsView_BASE)

BEGIN_MESSAGE_MAP(CResOrgProjectsView, CResOrgProjectsView_BASE)
	//{{AFX_MSG_MAP(CResOrgProjectsView)
	ON_WM_SIZE()
	ON_WM_CONTEXTMENU()
	ON_COMMAND(						ID_PROJ_OPEN,				OnCmdOpenProject)
	ON_COMMAND(						ID_PROJ_OPEN_MULTIPLE,		OnCmdOpenProjectsTogether)
	ON_UPDATE_COMMAND_UI(			ID_PROJ_OPEN_MULTIPLE,		OnUpdateOpenProjectsTogether)
	ON_COMMAND(						ID_PROJ_RENUMBER,			OnCmdRenumberProject)
	ON_UPDATE_COMMAND_UI(			ID_PROJ_RENUMBER,			OnUpdateRenumberProject)
	ON_COMMAND(						ID_PROJ_PROPERTIES,			OnCmdProjectProperties)
	ON_UPDATE_COMMAND_UI(			ID_PROJ_PROPERTIES,			OnUpdateProjectProperties)
		//}}AFX_MSG_MAP

	// The following are outside of ClassWizard's reach as it can't understand
	// them....
	ON_NOTIFY_REFLECT(	NM_DBLCLK,								OnDblClick)

END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView construction/destruction

CResOrgProjectsView::CResOrgProjectsView(void)
{
	m_bInitialised		= FALSE;
	m_nSortColumn		= 0;
	m_bSortAscending	= true;
}


CResOrgProjectsView::~CResOrgProjectsView(void)
{
	Clear();
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView overrides

/******************************************************************************
 *	This method is called by the framework before the creation of the
 *	window attached to this CWnd object.
 *
 *	This override is used to modify the window styles here to set the List
 *	control style to report view.
 *
 *	This is achieved by masking out the view style using LVS_TYPEMASK
 *	and setting the LVS_REPORT style. LVS_SINGLESEL is also set to allow
 *	only single selections.
 *
 *	Note that we DON'T want the LVS_SORTASCENDING style as this sorts items
 *	by item text and in this case we cannot have a comparison function.
 *
 ******************************************************************************/

BOOL CResOrgProjectsView::PreCreateWindow(CREATESTRUCT& cs)
{
	cs.style = (cs.style & ~LVS_TYPEMASK) | LVS_REPORT /*| LVS_SINGLESEL*/ | LVS_SHOWSELALWAYS;

	return CResOrgProjectsView_BASE::PreCreateWindow(cs);
}


void CResOrgProjectsView::OnInitialUpdate(void)
{
	// Change style to have:
	//
	//	1.	Flat header (requires CJListCtrl)
	//	2.	Full row selection (requires ComCtl32.dll v4.71)
	//
	if (!m_bInitialised)
	{
		CCJThemeHelper theme;
		if (!theme.IsAppThemed() )
		{
			SubclassHeader();
		}
		SetExtendedStyle(GetExtendedStyle() | LVS_EX_FULLROWSELECT);

		CRect rect;
		GetClientRect(rect);

		GetListCtrl().InsertColumn(0,
									_T("Project"),
									LVCFMT_LEFT,
									rect.Width(),
									-1);
		m_bInitialised = TRUE;
	}
	CResOrgProjectsView_BASE::OnInitialUpdate();
}


void CResOrgProjectsView::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint)
{
	UNREFERENCED_PARAMETER(pSender);
	UNREFERENCED_PARAMETER(pHint);

	switch (lHint)
	{
		case CLEAR_WORKSPACE:
			GetListCtrl().DeleteAllItems();
			Clear();
			break;

		case SHOW_WORKSPACE:
			GetListCtrl().DeleteAllItems();
			Clear();

			Workspace.GetProjects(m_arrayProjects);
			FillListCtrl();

			// If there's only one project, open its symbol
			// file automatically
			if (m_arrayProjects.GetSize() == 1)
			{
				IGenericProject* pProject = m_arrayProjects[0];
				if (NULL != pProject)
				{
					CString sProject = Workspace.GetName(pProject);

					ASSERT(!sProject.IsEmpty());

					if (!sProject.IsEmpty())
					{
						OpenProject(sProject,
									Options.WarnIfNextSymbolValuesInUse() );
					}
				}
			}
			break;


		default:
			GetListCtrl().DeleteAllItems();
			Clear();

			Workspace.GetProjects(m_arrayProjects);
			FillListCtrl();

			break;
	}
	GetListCtrl().EnableWindow( (m_arrayProjects.GetSize() > 0) );
}	


void CResOrgProjectsView::OnDraw(CDC* /*pDC*/)
{
	CResOrgProjectsDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
}


bool CResOrgProjectsView::SortList(int nColumn, bool bAscending)
{
	m_nSortColumn		= nColumn;
	m_bSortAscending	= bAscending;

	// Resort contents if sorted before
	if (m_nSortColumn >= 0)
	{
		DWORD lParam = MAKELONG(m_nSortColumn, m_bSortAscending);

		GetListCtrl().SortItems(ListViewCompareProc, lParam);

		return true;
	}
	return false;
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView diagnostics

#ifdef _DEBUG
void CResOrgProjectsView::AssertValid(void) const
{
	CResOrgProjectsView_BASE::AssertValid();
}


void CResOrgProjectsView::Dump(CDumpContext& dc) const
{
	CResOrgProjectsView_BASE::Dump(dc);
}


CResOrgProjectsDoc* CResOrgProjectsView::GetDocument(void) // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CResOrgProjectsDoc)));

	return (CResOrgProjectsDoc*)m_pDocument;
}
#endif //_DEBUG


/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView implementation

void CResOrgProjectsView::FillListCtrl(void)
{
	GetListCtrl().SetRedraw(FALSE);

	GetListCtrl().DeleteAllItems();

	CResOrgProjectsDoc* pDoc = GetDocument();
	if (NULL != pDoc)
	{
		int nItem = -1;

		for (int n = 0; n < m_arrayProjects.GetSize(); n++)
		{
			IGenericProject* pProject = m_arrayProjects[n];
			if (NULL != pProject)
			{
				CString sProject = Workspace.GetName(pProject);

				VERIFY(-1 != GetListCtrl().InsertItem(++nItem, sProject) );

				GetListCtrl().SetItemData(nItem, (DWORD)pProject);
			}
		}
	}
	SortList(m_nSortColumn, m_bSortAscending);

	GetListCtrl().SetRedraw(TRUE);
}


void CResOrgProjectsView::Clear(void)
{
	for (int n = 0; n < m_arrayProjects.GetSize(); n++)
	{
		IGenericProject* pProject = m_arrayProjects[n];
		if (NULL != pProject)
		{
			pProject->Release();
		}
	}
	m_arrayProjects.RemoveAll();
}


/******************************************************************************
 *	Static callback function for List Control sorting
 *
 *	The list control will then repeatedly call this to determine how to sort
 *	its data
 *
 ******************************************************************************/

int CALLBACK CResOrgProjectsView::ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	IGenericProject* pItem1 = (IGenericProject*)lParam1;
	IGenericProject* pItem2 = (IGenericProject*)lParam2;

	int nResult = 0;		// Default => Equal

	if ( (NULL != pItem1) && (NULL != pItem2) )
	{
		int nColumn			= LOWORD(lParamSort);
		BOOL bSortAscending	= HIWORD(lParamSort);

		switch (nColumn)
		{
			case 0:
				{
					CString sItem1 = Workspace.GetName(pItem1);
					CString sItem2 = Workspace.GetName(pItem2);

					nResult = lstrcmpi(sItem1, sItem2);

					if ( (sItem1.IsEmpty()) || (sItem2.IsEmpty()) )
					{
						nResult = -nResult;			// Modify sort so a blank entry is HIGHER than one with something in it
					}
				}
				break;

			default:
				return 0;
	   	}
		if (!bSortAscending)
		{
			nResult = -nResult;			// Sneaky way to reverse sort order...
		}
	}
	return nResult;
}


CDocument* CResOrgProjectsView::OpenProject(const CString& sProject,
											BOOL bCheckNextSymbolValues /*= TRUE*/)
{
	CDocument* pDoc = NULL;

	// First, extract the rc file name by parsing the .dsp file
	CString sResourceFile = Workspace.GetResourceFileName(sProject);
	if (!sResourceFile.IsEmpty())
	{
		// Retrieve the name of the symbol file by parsing the rc file
		CString sSymbolFile = ::GetSymbolFileName(sResourceFile);
		if (!sSymbolFile.IsEmpty())
		{
			pDoc = GetDocument()->GetOpenDocument(sSymbolFile);
			if (NULL != pDoc)
			{
				// If the file is already open, just activate it
				GetDocument()->SetActiveDocument(pDoc);
			}
			else
			{
				// ...otherwise, we have to open it...

				// To Do: convert to flash box
				//AfxMessageBox( "Displaying symbols for: " + sSymbolFile);

				CResOrgAddInApp* pApp = (CResOrgAddInApp*)::AfxGetApp();
				BOOL bCheckOption = pApp->CheckNextSymbolValues();
				pApp->CheckNextSymbolValues(FALSE);

				Workspace.CloseResourceFile(sResourceFile);

				pDoc = pApp->OpenDocumentFile(sSymbolFile);

				pApp->CheckNextSymbolValues(bCheckOption);

				ASSERT(NULL != pDoc);
			}
			CResOrgSymbolsDoc* pSymDoc = dynamic_cast<CResOrgSymbolsDoc*>(pDoc);
			if ( (NULL != pSymDoc) && bCheckNextSymbolValues)
			{
				// This is too intrusive if we're opening multiple files
				pSymDoc->CheckNextSymbolValues();
			}
		}
	}
	return pDoc;
}


int CResOrgProjectsView::DoNextSymbolValuesInUsePrompt(const CStringArray& arrayProjects)
{
	CString sProjects;

	for (int n = 0; n < arrayProjects.GetSize(); n++)
	{
		CString sLine;
	
		sLine.Format( _T("%s\\par\r\n"), arrayProjects[n]);	// Dontcha just love RTF???

		sProjects += sLine;
	}
	CNGMessageBox dlg;

	dlg.FormatMsgEx(MAKEINTRESOURCE(IDP_PRJ_SYM_NEXT_VALUES_IN_USE),
					_T("RTF"),
					sProjects);

	dlg.SetRtf();
	dlg.SetStandardIcon(IDI_WARNING);
	dlg.AddButton(IDOK, TRUE, TRUE, _T("OK") );

	return dlg.DoModal();
}


CString CResOrgProjectsView::GetSymbolFilePathName(const CString& sProject)
{
	CString sSymbolFilePathName;

	// First, extract the rc file name by parsing the .dsp file
	CString sResourceFilePathName = Workspace.GetResourceFileName(sProject);
	if (!sResourceFilePathName.IsEmpty())
	{
		// Retrieve the name of the symbol file by parsing the rc file
		sSymbolFilePathName = ::GetSymbolFileName(sResourceFilePathName);
	}
	return sSymbolFilePathName;
}



/////////////////////////////////////////////////////////////////////////////
// CResOrgProjectsView message handlers

void CResOrgProjectsView::OnSize(UINT nType, int cx, int cy) 
{
	CResOrgProjectsView_BASE::OnSize(nType, cx, cy);
	
	if (m_bInitialised)
	{
		AutoSizeColumn();
	}
}


//	Context Menu handler
void CResOrgProjectsView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	UNREFERENCED_PARAMETER(pWnd);

	// Make sure window is active
	GetParentFrame()->ActivateFrame();

	// Convert to client coordinates for hit testing
	// Note that TrackPopupMenu() expects its coordinates to be screen, not client!
	CPoint ptClient = point;
	ScreenToClient(&ptClient);

	UINT nFlags = 0;
	int nIndex = GetListCtrl().HitTest(ptClient, &nFlags);
	
	if (nIndex >= 0)
	{
		CCJMenu menu;
		if (menu.LoadMenu(IDM_PRJ_CONTEXT_MENU))
		{
			menu.LoadToolbar(IDM_PRJ_CONTEXT_MENU);

			CMenu* pPopup = menu.GetSubMenu(0);
			ASSERT(NULL != pPopup);

			pPopup->SetDefaultItem(ID_PROJ_OPEN);
			pPopup->TrackPopupMenu(TPM_RIGHTBUTTON | TPM_LEFTALIGN,
								   point.x,
								   point.y,
								   AfxGetMainWnd()); // route commands through main window
			return;
		}
	}
	Default();									// Default message handling if we didn't do anything
}



void CResOrgProjectsView::OnDblClick(NMHDR* /*pNMHDR*/, LRESULT* pResult) 
{
	*pResult = 0;

	OnCmdOpenProject();
}


void CResOrgProjectsView::OnCmdOpenProject(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			CStringArray arrayProjects;

			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CResOrgSymbolsDoc* pSymDoc = DYNAMIC_DOWNCAST(	CResOrgSymbolsDoc,
																	OpenProject(sProject,
																	FALSE ) );
					if (NULL != pSymDoc)
					{
						if (pSymDoc->CheckNextSymbolValues(FALSE) )
						{
							arrayProjects.Add(sProject);
						}
					}
					else
					{
						CString sMsg;
						sMsg.Format(IDP_PRJ_NO_SYM_FILE, sProject);

						::AfxMessageBox(sMsg,
										MB_OK | MB_ICONEXCLAMATION);
					}
				}
			}
			if (Options.WarnIfNextSymbolValuesInUse())
			{
				if (arrayProjects.GetSize() > 0)
				{
					DoNextSymbolValuesInUsePrompt(arrayProjects);
				}
			}
		}
	}
}


void CResOrgProjectsView::OnCmdOpenProjectsTogether(void)
{
	// TO DO: Display a progress bar if there's more than a handful of files
	int nSelCount = GetListCtrl().GetSelectedCount();

	if (nSelCount > 0)
	{
		CResOrgProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			CStringArray arraySymbolFilePathNames;

			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CString sSymbolFilePathName = GetSymbolFilePathName(sProject);

					if (!sSymbolFilePathName.IsEmpty())
					{
						arraySymbolFilePathNames.Add(sSymbolFilePathName);
					}
				}
			}
			if (arraySymbolFilePathNames.GetSize() > 0)
			{
				CResOrgAddInApp* pApp = static_cast<CResOrgAddInApp*>( ::AfxGetApp() );

				pApp->OpenMultiFileSymbolsView(arraySymbolFilePathNames);
			}
			else
			{
				::AfxMessageBox(_T("No resource symbol files were found in the selected projects"),
								MB_OK | MB_ICONSTOP);
			}
		}
	}
}


void CResOrgProjectsView::OnUpdateOpenProjectsTogether(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() >= 2);
}


void CResOrgProjectsView::OnCmdRenumberProject(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CResOrgSymbolsDoc* pDoc = dynamic_cast<CResOrgSymbolsDoc*>( OpenProject(sProject, FALSE) );
					if (NULL != pDoc)
					{
						if (pDoc->GetSymbolBuffer()->GetSymbolCount() > 0)
						{
							AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_TOOLS_RENUMBER);
						}
						else
						{
							AfxMessageBox(	_T("This file contains no symbols"),
											MB_OK | MB_ICONSTOP);
						}
					}
				}
			}
		}
	}
}


void CResOrgProjectsView::OnUpdateRenumberProject(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() == 1);
}


void CResOrgProjectsView::OnCmdProjectProperties(void)
{
	if (GetListCtrl().GetSelectedCount() > 0)
	{
		CResOrgProjectsDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		if (NULL != pDoc)
		{
			POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
			while (pos != NULL)
			{
				int nItem = GetListCtrl().GetNextSelectedItem(pos);
				if (nItem >= 0)
				{
					CString sProject = GetListCtrl().GetItemText(nItem, 0);

					CResOrgSymbolsDoc* pDoc = dynamic_cast<CResOrgSymbolsDoc*>( OpenProject(sProject, FALSE) );
					if (NULL != pDoc)
					{
						::AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_PROPERTIES);
					}
				}
			}
		}
	}
}


void CResOrgProjectsView::OnUpdateProjectProperties(CCmdUI* pCmdUI)
{
	pCmdUI->Enable( GetListCtrl().GetSelectedCount() == 1);
}

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)

Share

About the Author

Anna-Jayne Metcalfe
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!

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150901.1 | Last Updated 10 Jan 2005
Article Copyright 2001 by Anna-Jayne Metcalfe
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid