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

📄 resorgmdiframewnd.cpp

📁 一个vc中管理资源文件ID的插件
💻 CPP
字号:
/************************************************************************
 *
 *                 Resource ID Organiser Utility Library
 *
 *       (c) Copyright 2000-2001 by Andy Metcalfe (andy.metcalfe@lineone.net)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResOrgMDIFrameWnd.cpp
 *
 *  Description : CResOrgMDIFrameWnd - MDI main frame window class
 *
 *  Compiler    : Microsoft Visual C++ 6.0, Service Pack 3 or 4
 *                                                                       
 *  Target                                                               
 *  Environment : Windows 98/NT
 *
 *  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 Andy 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.resorg.co.uk 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/ResOrgUtils/ResOrgMDIFrameWnd.cpp $
 *   $Revision: 2 $
 *       $Date: 2/06/01 19:51 $
 *     $Author: Andy $
 *
 *    $History: ResOrgMDIFrameWnd.cpp $
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 2/06/01    Time: 19:51
 * Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
 * Comment changes only
 * 
 * *****************  Version 1  *****************
 * User: Andy         Date: 2/06/01    Time: 16:49
 * Created in $/Projects/AddIns/ResOrg/ResOrgUtils
 * 
 *
 * $Nokeywords: $
 *
 ************************************************************************/

// ResOrgMDIFrameWnd.cpp : implementation of the CResOrgMDIFrameWnd class
//

#include "StdAfx.h"
#include "ResOrgUtils_Priv.h"

#include "ResOrgSymbolsDoc.h"

#include "ResOrgMDIFrameWnd.h"


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


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd

IMPLEMENT_DYNCREATE(CResOrgMDIFrameWnd, CResOrgMDIFrameWnd_BASE)

BEGIN_MESSAGE_MAP(CResOrgMDIFrameWnd, CResOrgMDIFrameWnd_BASE)

	//{{AFX_MSG_MAP(CResOrgMDIFrameWnd)
	ON_WM_CREATE()
	ON_WM_DROPFILES()
	ON_WM_CLOSE()
	ON_UPDATE_COMMAND_UI(	ID_FILE_CLOSE,					OnUpdateFileClose)
	ON_UPDATE_COMMAND_UI(	ID_FILE_SAVE,					OnUpdateFileSaveEtc)
	ON_UPDATE_COMMAND_UI(	ID_FILE_SAVE_AS,				OnUpdateFileSaveEtc)
	ON_UPDATE_COMMAND_UI(	ID_INDICATOR_SYM_COUNT,			OnUpdateSymbolCount)
	ON_UPDATE_COMMAND_UI(	ID_INDICATOR_SYM_CONFLICTS,		OnUpdateSymbolConflicts)
	//}}AFX_MSG_MAP

END_MESSAGE_MAP()


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


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd construction/destruction

CResOrgMDIFrameWnd::CResOrgMDIFrameWnd(void)
{
}


CResOrgMDIFrameWnd::~CResOrgMDIFrameWnd(void)
{
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd virtual overrides

BOOL CResOrgMDIFrameWnd::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if (Options.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo) )
	{
		return TRUE;
	}
	return CResOrgMDIFrameWnd_BASE::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd diagnostics

#ifdef _DEBUG
void CResOrgMDIFrameWnd::AssertValid(void) const
{
	CResOrgMDIFrameWnd_BASE::AssertValid();
}


void CResOrgMDIFrameWnd::Dump(CDumpContext& dc) const
{
	CResOrgMDIFrameWnd_BASE::Dump(dc);
}

#endif //_DEBUG


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd operations

CDocument* CResOrgMDIFrameWnd::MDIGetActiveDocument(void) const
{
	CDocument* pDoc = NULL;

	CMDIChildWnd * pwndChild = MDIGetActive();

	if (NULL != pwndChild)
	{
		pDoc = pwndChild->GetActiveDocument();
	}
	return pDoc;
} 


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd implementation
// (none)


/////////////////////////////////////////////////////////////////////////////
// CResOrgMDIFrameWnd message handlers

int CResOrgMDIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CResOrgMDIFrameWnd_BASE::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

		if (!m_wndStatusBar.CreateStatusBar(this,
											indicators,
											sizeof(indicators)/sizeof(UINT) ) )
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// Resize the status bar panes
	UINT uID = 0;
	UINT eStyle = 0;
	int nWidth = 0;
	m_wndStatusBar.GetPaneInfo(	m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
								uID,
								eStyle,
								nWidth);

	m_wndStatusBar.SetPaneInfo(	m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
								uID,
								eStyle,
								nWidth * 2);

	m_wndStatusBar.GetPaneInfo(	m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_CONFLICTS),
								uID,
								eStyle,
								nWidth);

	m_wndStatusBar.SetPaneInfo(	m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_CONFLICTS),
								uID,
								eStyle,
								nWidth * 2);

	// The "Symbol Count" pane shows as white on a blue background, unless it's disabled
	m_wndStatusBar.SetFgColor(	m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
								RGB(255, 255, 255),					// White
								::GetSysColor(COLOR_GRAYTEXT) );	// Dark Grey (usually)

	m_wndStatusBar.SetBkColor(	m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT),
								RGB(0, 0, 128),						// Dark blue
								::GetSysColor(COLOR_3DFACE) );		// Grey (usually)

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);


	// The only line of code you need to support 
	// TabbedMDI interface automatically
	//
	VERIFY(m_MTIClientWnd.Attach(this));

	return 0;
}


/******************************************************************************
 *	The framework calls this override as a signal that files have been dropped
 *	within the window
 *
 ******************************************************************************/

void CResOrgMDIFrameWnd::OnDropFiles(HDROP hDropInfo) 
{
	SetActiveWindow();							// Activate us first
	UINT uFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);

	CStringArray arrayUnsuitableFiles;

	CWinApp* pApp = AfxGetApp();
	ASSERT(NULL != pApp);
	if (NULL != pApp)
	{
		for (UINT n = 0; n < uFiles; n++)
		{
			// Extract the name of the file
			TCHAR szFileName[_MAX_PATH];
			::DragQueryFile(hDropInfo, n, szFileName, _MAX_PATH);

			// Check to see if we can open it; if so proceed
			CNGSplitPath split(szFileName);
			if (0 == split.GetExtension().CompareNoCase( _T(".h") ) )
			{
				pApp->OpenDocumentFile(szFileName);
			}
			else
			{
				arrayUnsuitableFiles.Add(split.GetFileName() + split.GetExtension() );
			}
		}
	}
	if (arrayUnsuitableFiles.GetSize() > 0)
	{
		CString sMsg;
		sMsg.LoadString(IDP_RESORG_FILE_BAD_TYPE);

		for (int n = 0; n < arrayUnsuitableFiles.GetSize(); n++)
		{
			sMsg += _T("\t") + arrayUnsuitableFiles[n] + _T("\n");
		}
		AfxMessageBox(sMsg, MB_OK | MB_ICONSTOP);
	}
	::DragFinish(hDropInfo);
}


void CResOrgMDIFrameWnd::OnUpdateFileClose(CCmdUI* pCmdUI)
{
	CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());

	pCmdUI->Enable(NULL != pDoc);
}


void CResOrgMDIFrameWnd::OnUpdateFileSaveEtc(CCmdUI* pCmdUI)
{
	CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
	if (pDoc != NULL)
	{
		pCmdUI->ContinueRouting();
	}
	else
	{
		pCmdUI->Enable(FALSE);
	}
}


void CResOrgMDIFrameWnd::OnUpdateSymbolCount(CCmdUI* pCmdUI)
{
	int nPane = m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_COUNT);
	ASSERT(nPane >= 0);

	CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
	if (pDoc != NULL)
	{
		CString sText;
		sText.Format(pCmdUI->m_nID, pDoc->GetSymbolBuffer()->GetSymbolCount() );

		m_wndStatusBar.SetMode(nPane, XSB_ICON_AND_TEXT);
		m_wndStatusBar.SetIconAndText(nPane, IDI_SYM_RESOURCE, sText);
		pCmdUI->Enable(TRUE);
	}
	else
	{
		m_wndStatusBar.SetMode(nPane, XSB_TEXT);
		m_wndStatusBar.SetText(nPane, _T(""), _T("") );

		pCmdUI->SetText( _T("") );
		pCmdUI->Enable(FALSE);
	}
}


void CResOrgMDIFrameWnd::OnUpdateSymbolConflicts(CCmdUI* pCmdUI)
{
	int nPane = m_wndStatusBar.CommandToIndex(ID_INDICATOR_SYM_CONFLICTS);
	ASSERT(nPane >= 0);

	CResOrgSymbolsDoc* pDoc = DYNAMIC_DOWNCAST(CResOrgSymbolsDoc, MDIGetActiveDocument());
	if (pDoc != NULL)
	{
		int nConflicts = pDoc->GetSymbolBuffer()->GetConflictCount();

		CString sText;
		sText.Format(pCmdUI->m_nID, nConflicts);

		UINT uIconID = 0;
		if (nConflicts > 0)
		{
			uIconID = IDI_SYM_WARNING;
			
			m_wndStatusBar.SetFgColor(nPane, RGB(255, 255, 0) );	// Yellow
			m_wndStatusBar.SetBkColor(nPane, RGB(255, 0, 0) );		// Red
		}
		else
		{
			uIconID = IDI_SYM_INFORMATION;

			m_wndStatusBar.SetFgColor(nPane, RGB(255, 255, 255) );	// White
			m_wndStatusBar.SetBkColor(nPane, RGB(0, 128, 0) );		// Dark Green
		}

		m_wndStatusBar.SetMode(nPane, XSB_ICON_AND_TEXT);
		m_wndStatusBar.SetIconAndText(nPane, uIconID, sText);
		pCmdUI->Enable(TRUE);
	}
	else
	{
		m_wndStatusBar.SetMode(nPane, XSB_TEXT);
		m_wndStatusBar.SetText(nPane, _T(""), _T("") );
		m_wndStatusBar.SetFgColor(nPane, ::GetSysColor(COLOR_GRAYTEXT) );	// Dark Grey (usually)
		m_wndStatusBar.SetBkColor(nPane, GetSysColor(COLOR_3DFACE) );

		pCmdUI->SetText( _T("") );
		pCmdUI->Enable(FALSE);
	}
}

⌨️ 快捷键说明

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