⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resourcesymbolfilespage.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Core Library
 *
 * (c) Copyright 2000-2003 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResourceSymbolFilesPage.cpp
 *
 *  Description : CResourceSymbolFilesPage - "File" page for
 *                resource symbol file properties (used as the first
 *                page of the File Properties Dialog when multiple files
 *                are opened)
 *                
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or later
 *                Microsoft Visual C++ .NET 2002
 *                                                                       
 *  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/ResOrgCore/ResourceSymbolFilesPage.cpp $
 *   $Revision: 5 $
 *       $Date: 26/06/03 20:18 $
 *     $Author: Anna $
 *
 *    $History: ResourceSymbolFilesPage.cpp $
 * 
 * *****************  Version 5  *****************
 * User: Anna         Date: 26/06/03   Time: 20:18
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Added resizing support
 * 
 * *****************  Version 4  *****************
 * User: Anna         Date: 26/03/03   Time: 14:12
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * CResourceSymbolFilesPage now disables the "Remove" button where
 * appropriate to prevent you from removing the last file (a very bad
 * idea, trust me)
 * 
 * *****************  Version 3  *****************
 * User: Anna         Date: 15/02/03   Time: 21:19
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Multiple selections can now be made on the "Files" page...when this is
 * so the other tabs disappear as they don't apply
 * 
 * *****************  Version 2  *****************
 * User: Anna         Date: 28/01/03   Time: 21:19
 * Updated in $/Projects/AddIns/ResOrg/ResOrgCore
 * Improved multi-file support by allowing files to be Added/Removed from
 * a multi-file display via the File Properties Dialog
 * 
 * *****************  Version 1  *****************
 * User: Anna         Date: 19/01/03   Time: 17:23
 * Created in $/Projects/AddIns/ResOrg/ResOrgCore
 * CResourceSymbolFilesPage - "File" page for resource symbol file
 * properties (used as the first page of the File Properties Dialog when
 * multiple files are opened)
 * 
 * $Nokeywords: $
 *
 ************************************************************************/


#include "StdAfx.h"
#include "ResOrgCore_Priv.h"

#include "ResourceSymbolManagerMultiFile.h"

#include "ResourceSymbolFilesPage.h"



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


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolFilesPage property page

IMPLEMENT_DYNAMIC(CResourceSymbolFilesPage, CResourceSymbolFilesPage_BASE)


// Registered message definitions
const UINT WM_SEL_FILES_CHANGED	= ::RegisterWindowMessage( _T("SelectedFilesChanged") );



CResourceSymbolFilesPage::CResourceSymbolFilesPage(void)
	: CResourceSymbolFilesPage_BASE(CResourceSymbolFilesPage::IDD)
{
	m_pSymbols		= NULL;

	//{{AFX_DATA_INIT(CResourceSymbolFilesPage)
	//}}AFX_DATA_INIT
}


CResourceSymbolFilesPage::~CResourceSymbolFilesPage(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolFilesPage virtual overrides

void CResourceSymbolFilesPage::DoDataExchange(CDataExchange* pDX)
{
	CResourceSymbolFilesPage_BASE::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CResourceSymbolFilesPage)
	DDX_Control(pDX,				IDC_SYM_FILES,					m_ctrlFiles);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CResourceSymbolFilesPage, CResourceSymbolFilesPage_BASE)
	//{{AFX_MSG_MAP(CResourceSymbolFilesPage)
	ON_NOTIFY(	LVN_ITEMCHANGED,	IDC_SYM_FILES,					OnItemChangedFilesCtrl)
	ON_BN_CLICKED(					IDC_SYM_FILE_ADD,				OnClickedAddFile)
	ON_BN_CLICKED(					IDC_SYM_FILE_REMOVE,			OnClickedRemoveFile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


BOOL CResourceSymbolFilesPage::OnInitDialog(void)
{
	BOOL bResult = CResourceSymbolFilesPage_BASE::OnInitDialog();

	m_Resizer.Add( IDC_SYM_FILES,			0,   0,   100, 100);
	m_Resizer.Add( IDC_SYM_FILE_ADD,		0,   100, 0,   0);
	m_Resizer.Add( IDC_SYM_FILE_REMOVE,		0,   100, 0,   0);

	ASSERT(NULL != m_pSymbols);		// Must be set first

	if (NULL != m_pSymbols)
	{
		m_ctrlFiles.AddFiles( static_cast<CResourceSymbolManagerMultiFile*>(m_pSymbols) );

		ASSERT(m_ctrlFiles.GetItemCount() > 0);

		// Select the first item by default
		// This is safe since the list control should NEVER be empty
		m_ctrlFiles.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);

		SetAvailableControls();
	}
	return bResult;
}


BOOL CResourceSymbolFilesPage::OnSetActive(void)
{
	CSymbolManagerPtrArray arrayManagers;
	m_ctrlFiles.GetSelection(arrayManagers);

	if (1 == arrayManagers.GetSize() )
	{
		CResourceSymbolManager* pMngr = arrayManagers[0];
		ASSERT(NULL != pMngr);

		if (NULL != pMngr)
		{
			SetFile(pMngr);
		}
	}
	else
	{
		SetFile(NULL);
	}

	return CResourceSymbolFilesPage_BASE::OnSetActive();
}



/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolFilesPage operations

void CResourceSymbolFilesPage::SetAvailableControls(void)
{
	if (NULL != m_pSymbols)
	{
		int nFiles = static_cast<CResourceSymbolManagerMultiFile*>(m_pSymbols)->GetSymbolFileCount();

		CSymbolManagerPtrArray arrayManagers;
		m_ctrlFiles.GetSelection(arrayManagers);

		int nSelFiles = arrayManagers.GetSize();

		// Removing the last file is a really BAD idea
		EnableDlgControl(IDC_SYM_FILE_REMOVE, (nFiles > 1) && (nSelFiles < nFiles) );
	}
}


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolFilesPage implementation

// Update the othe pages in the property sheet with the properties of
// the selected file
void CResourceSymbolFilesPage::SetFile(CResourceSymbolManager* pMngr)
{
	CPropertySheet* pParent = DYNAMIC_DOWNCAST(CPropertySheet, GetParent() );
	ASSERT(NULL != pParent);

	if (NULL != pParent)
	{
		for (int n = 0; n < pParent->GetPageCount(); n++)
		{
			CResourceSymbolFilePropertyPage* pPage = DYNAMIC_DOWNCAST(	CResourceSymbolFilePropertyPage,
																		pParent->GetPage(n) );
			ASSERT(NULL != pPage);

			if ( (NULL != pPage) && (pPage != this) )
			{
				pPage->SetSymbolManager(pMngr);
			}
		}
	}
}


/////////////////////////////////////////////////////////////////////////////
// CResourceSymbolFilesPage message handlers

void CResourceSymbolFilesPage::OnItemChangedFilesCtrl(NMHDR* pNMHDR, LRESULT* pResult) 
{
	*pResult = 0;

	LPNMLISTVIEW pLV = (LPNMLISTVIEW)pNMHDR;
	if (0 != (pLV->uChanged & LVIF_STATE) )
	{
		CSymbolManagerPtrArray arrayManagers;
		m_ctrlFiles.GetSelection(arrayManagers);

		CWnd* pParent = CNGWizardPage_BASE::GetParent();
		ASSERT(NULL != pParent);

		if (NULL != pParent)
		{
			pParent->SendMessage(WM_SEL_FILES_CHANGED, (WPARAM)arrayManagers.GetSize(), (LPARAM)&arrayManagers);
		}

		if (1 == arrayManagers.GetSize() )
		{
			CResourceSymbolManager* pMngr = arrayManagers[0];
			ASSERT(NULL != pMngr);

			if (NULL != pMngr)
			{
				SetFile(pMngr);
			}
		}
		else
		{
			SetFile(NULL);
		}
	}
	SetAvailableControls();
}



void CResourceSymbolFilesPage::OnClickedAddFile(void) 
{
	CResourceSymbolManagerMultiFile* pMngr = static_cast<CResourceSymbolManagerMultiFile*>(m_pSymbols);
	if (NULL != pMngr)
	{
		#if _MSC_VER < 1300		// BXFileDialog doesn't work with VC7 yet
			BXFileDialog dlg(	TRUE,												// Open
								FALSE,												// No preview
								TRUE,												// Resizeable
								CString( (LPCTSTR)IDS_FILE_FILTER_SYM_FILES_EXT),	// Default extension
								NULL,												// Default filename
								OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST,				// Flags
								CString( (LPCTSTR)IDS_FILE_FILTER_SYM_FILES),		// File filter
								::AfxGetMainWnd() );								// Parent window

			DWORD dwVersion		= LOWORD(::GetVersion() );

			DWORD dwMajor		= LOBYTE(dwVersion);
			DWORD dwMinor		= HIBYTE(dwVersion);
			DWORD dwUseableVer	= (dwMajor << 8) + dwMinor;

			if (dwUseableVer >= 0x501)
			{
				// Use the VS.NET visual style on WinXP and later
				dlg.SetAppearance(BXFileDialog::APPEARANCE_VSDOTNET);
			}
		#else
			CFileDialog dlg(	TRUE,												// Open
								CString( (LPCTSTR)IDS_FILE_FILTER_WORKSPACES_EXT),	// Default extension
								NULL,												// Default filename
								OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ENABLESIZING,
																					// Flags
								CString( (LPCTSTR)IDS_FILE_FILTER_WORKSPACES),		// File filter
								::AfxGetMainWnd() );								// Parent window
		#endif

		if (IDOK == dlg.DoModal() )
		{
			// Open and parse it (via the document)
			CString sPathName = dlg.GetPathName();

			if (!pMngr->IsSymbolFileLoaded(sPathName) )
			{
				CResourceSymbolManager* pFile = pMngr->AddSymbolFile(sPathName);
				if (NULL != pFile)
				{
					m_ctrlFiles.AddFile(pFile);

					m_ctrlFiles.UpdateAllFiles();

					if (NULL != m_pDoc)
					{
						m_pDoc->UpdateAllViews(NULL, SYM_REFRESH, NULL);
					}
				}
			}
			else
			{
				CNGSplitPath split(sPathName);
				
				CString sMsg;
				sMsg.Format(IDP_SYM_FILE_ALREADY_LOADED,
							split.GetFileName() + split.GetExtension() );

				::AfxMessageBox(sMsg, MB_OK | MB_ICONEXCLAMATION);
			}
		}
	}
}


void CResourceSymbolFilesPage::OnClickedRemoveFile(void) 
{
	CResourceSymbolManagerMultiFile* pMngr = static_cast<CResourceSymbolManagerMultiFile*>(m_pSymbols);
	if (NULL != pMngr)
	{
		CSymbolManagerPtrArray arrayManagers;
		m_ctrlFiles.GetSelection(arrayManagers);

		for (int n = 0; n < arrayManagers.GetSize(); n++)
		{
			CResourceSymbolManager* pFile = arrayManagers[n];

			if (NULL != pFile)
			{
				m_ctrlFiles.RemoveFile(pFile);

				pMngr->RemoveSymbolFile(pFile->GetPathName() );

			}
		}

		m_ctrlFiles.UpdateAllFiles();

		if (NULL != m_pDoc)
		{
			m_pDoc->UpdateAllViews(NULL, SYM_REFRESH, NULL);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -