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

📄 resorgapp.cpp

📁 一个vc中管理资源文件ID的插件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/************************************************************************
 *
 *                   Resource ID Organiser Application
 *
 *       (c) Copyright 2000 by Andy Metcalfe (andy.metcalfe@lineone.net)
 *                         All rights reserved.
 *
 ************************************************************************
 *                                                                       
 *  Filename    : ResOrgApp.cpp
 *
 *  Description : CResOrgApp - application 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/ResOrgApp/ResOrgApp.cpp $
 *   $Revision: 23 $
 *       $Date: 24/07/01 11:40 $
 *     $Author: Andy $
 *
 *    $History: ResOrgApp.cpp $
 * 
 * *****************  Version 23  *****************
 * User: Andy         Date: 24/07/01   Time: 11:40
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Corrected the Mailing List Prompt to point at the new mailing list
 * 
 * *****************  Version 22  *****************
 * User: Andy         Date: 8/07/01    Time: 16:57
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Integrated BXFileDialog module (replaces Office2KDlg)
 * 
 * *****************  Version 21  *****************
 * User: Andy         Date: 2/07/01    Time: 22:46
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Added additional web commands; all now obtain URLs from options
 * 
 * *****************  Version 20  *****************
 * User: Andy         Date: 5/06/01    Time: 19:31
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Bug fix for context help support
 * 
 * *****************  Version 19  *****************
 * User: Andy         Date: 2/06/01    Time: 19:49
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Corrected OnUpdateWindowClose() so it works if only non-Symbol displays
 * are open
 * 
 * *****************  Version 18  *****************
 * User: Andy         Date: 2/06/01    Time: 16:59
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * CResOrgApp::CloseOpenDocuments() now closes ALL documents, not just
 * symbol docs
 * 
 * *****************  Version 17  *****************
 * User: Andy         Date: 2/06/01    Time: 16:52
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Dropped MRU to 9 entries (was 10 before)
 * 
 * *****************  Version 16  *****************
 * User: Andy         Date: 26/05/01   Time: 15:25
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Help support
 * 2.  Added a prompt to ask about subscribing to the Mailing List
 * 
 * *****************  Version 15  *****************
 * User: Andy         Date: 22/05/01   Time: 16:00
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Minor bug fix
 * 
 * *****************  Version 14  *****************
 * User: Andy         Date: 22/05/01   Time: 6:51
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Added "ResOrg Mailing List" command to the Help Menu
 * 2.  Tidied up initialisation of document templates
 * 
 * *****************  Version 13  *****************
 * User: Andy         Date: 16/05/01   Time: 21:06
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Added latest version checking
 * 
 * *****************  Version 12  *****************
 * User: Andy         Date: 12/05/01   Time: 6:49
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Check whether DevStudio is available before asking whether to load the
 * add-in
 * 
 * *****************  Version 11  *****************
 * User: Andy         Date: 26/04/01   Time: 19:46
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Added additional "ResOrg on the Web" commands
 * 2.  Renamed Resource.h to ResOrgAddIn_Res.h
 * 
 * *****************  Version 10  *****************
 * User: Andy         Date: 21/04/01   Time: 7:33
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Added splash screen
 * 2.  The workspace display is now shown when a workspace is opened, and
 * hidden when it is closed
 * 
 * *****************  Version 9  *****************
 * User: Andy         Date: 5/04/01    Time: 6:09
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Added check for version expiry (conditional compilation)
 * 
 * *****************  Version 8  *****************
 * User: Andy         Date: 2/04/01    Time: 17:52
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Bug fixes to "Recent Workspaces" code
 * 
 * *****************  Version 7  *****************
 * User: Andy         Date: 5/03/01    Time: 19:15
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Added workspace open/close related code (some of which was in the
 * mainframe previously)
 * 2.  Tidied up the code a bit
 * 
 * *****************  Version 6  *****************
 * User: Andy         Date: 2/03/01    Time: 17:19
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * Tidied up the code a bit
 * 
 * *****************  Version 5  *****************
 * User: Andy         Date: 17/02/01   Time: 7:13
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  CResOrgSymbolsView => CResOrgSymbolsListView
 * 2.  When checking the path to the add-in on startup, the path used will
 * be that of the app (this should ensure that the right version of the
 * add-in is loaded)
 * 
 * *****************  Version 4  *****************
 * User: Andy         Date: 5/12/00    Time: 20:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Added "ResOrg on the Web" support
 * 2.  Raised version to 1.2.1
 * 
 * *****************  Version 3  *****************
 * User: Andy         Date: 3/12/00    Time: 8:32
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Updated registry key
 * 2.  Added a prompt dialog to ask whether to load the ResOrg add-in when
 * the application starts
 * 
 * *****************  Version 2  *****************
 * User: Andy         Date: 29/11/00   Time: 18:37
 * Updated in $/Projects/AddIns/ResOrg/ResOrgApp
 * 1.  Moved Office2KDlg code to its own DLL
 * 2.  Added file banners
 *
 * $Nokeywords: $
 *
 ************************************************************************/

// ResOrgApp.cpp : implementation of the CResOrgApp class
//

#include "StdAfx.h"
#include <AfxHtml.h>

#include "ResOrgApp.h"

#include "ResOrgAddInLoadPrompt.h"
#include "ResOrgAppProjectsDoc.h"
#include "MainFrame.h"
#include "ChildFrame.h"


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



/////////////////////////////////////////////////////////////////////////////
// The one and only CResOrgApp object

CResOrgApp theApp;



/////////////////////////////////////////////////////////////////////////////
// CResOrgApp

BEGIN_MESSAGE_MAP(CResOrgApp, CWinApp)
	//{{AFX_MSG_MAP(CResOrgApp)
	ON_COMMAND(				ID_RESORG_WEB,				OnCmdResOrgWebsite)
	ON_COMMAND(				ID_RESORG_WEB_FAQ,			OnCmdResOrgFAQ)
	ON_UPDATE_COMMAND_UI(	ID_RESORG_WEB_FAQ,			OnUpdateResOrgFAQ)
	ON_COMMAND(				ID_RESORG_WEB_DISCUSSIONS,	OnCmdResOrgDiscussionBoard)
	ON_UPDATE_COMMAND_UI(	ID_RESORG_WEB_DISCUSSIONS,	OnUpdateResOrgDiscussionBoard)
	ON_COMMAND(				ID_RESORG_WEB_BUGS,			OnCmdResOrgKnownBugs)
	ON_UPDATE_COMMAND_UI(	ID_RESORG_WEB_BUGS,			OnUpdateResOrgKnownBugs)
	ON_COMMAND(				ID_RESORG_MAILING_LIST,		OnCmdResOrgMailingList)
	ON_UPDATE_COMMAND_UI(	ID_RESORG_MAILING_LIST,		OnUpdateResOrgMailingList)
	ON_COMMAND(				ID_APP_ABOUT,				OnCmdAbout)
	ON_COMMAND(				ID_RESORG_OPTIONS,			OnCmdOptions)
	ON_COMMAND(				ID_WORKSPACE_OPEN,			OnCmdOpenWorkspace)
	ON_COMMAND(				ID_WORKSPACE_CLOSE,			OnCmdCloseWorkspace)
	ON_UPDATE_COMMAND_UI(	ID_WORKSPACE_CLOSE,			OnUpdateCloseWorkspace)
	ON_COMMAND(				ID_WINDOW_CLOSE_ALL,		OnCmdWindowCloseAll)
	ON_UPDATE_COMMAND_UI(	ID_WINDOW_CLOSE_ALL,		OnUpdateWindowCloseAll)
	//}}AFX_MSG_MAP

	// Standard file based document commands
	ON_COMMAND(				ID_FILE_NEW,				CResOrgApp_BASE::OnFileNew)
	ON_COMMAND(				ID_FILE_OPEN,				CResOrgApp_BASE::OnFileOpen)

	// Standard print setup command
	ON_COMMAND(				ID_FILE_PRINT_SETUP,		CResOrgApp_BASE::OnFilePrintSetup)

	// MRU - most recently used workspace menu
	ON_UPDATE_COMMAND_UI(	ID_WORKSPACE_MRU_FILE1,		OnUpdateRecentWorkspaceMenu)
	ON_COMMAND_EX_RANGE(	ID_WORKSPACE_MRU_FILE1,
							ID_WORKSPACE_MRU_FILE1+15,	OnCmdOpenRecentWorkspace)

	ON_COMMAND(				ID_HELP_FINDER,				CResOrgApp_BASE::OnHelpFinder)
	ON_COMMAND(				ID_HELP,					CResOrgApp_BASE::OnHelp)
	ON_COMMAND(				ID_CONTEXT_HELP,			CResOrgApp_BASE::OnContextHelp)
	ON_COMMAND(				ID_DEFAULT_HELP,			CResOrgApp_BASE::OnHelpFinder)

END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CResOrgApp construction/destruction

CResOrgApp::CResOrgApp(void)
{
	m_plistRecentWorkspaces	= NULL;
	m_pHtmlDocTemplate		= NULL;

	m_pProjectsDoc			= NULL;	

	m_pwndSplash			= NULL;
}


CResOrgApp::~CResOrgApp(void)
{
	if (NULL != m_pwndSplash)
	{
		delete m_pwndSplash;
		m_pwndSplash = NULL;
	}

	if (NULL != m_pProjectsDoc)
	{
		// m_pProjectsDoc will auto-delete when the last view (the
		// Workspace) is removed. Hence, we don't need to do anything
		// here; this code is included for completeness
		m_pProjectsDoc = NULL;
	}
	if (NULL != m_plistRecentWorkspaces)
	{
		delete m_plistRecentWorkspaces;
	}
	if (NULL != m_pHtmlDocTemplate)
	{
		delete m_pHtmlDocTemplate;
	}
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgApp virtual overrides

BOOL CResOrgApp::InitInstance(void)
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need.
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

   // Check the version of the common controls library.
	// (we need at least v5.80 to support Wizard97)
	CNGModuleVersion ver;
	ver.GetFileVersionInfo( _T("comctl32.dll") );

    DWORD dwTargetVerMS = MAKELONG(80, 5);

    if (ver.dwFileVersionMS < dwTargetVerMS)
    {
		CString sVersion = ver.GetValue( _T("FileVersion") );

		DoCommonControlsVersionPrompt(sVersion);

        return FALSE;
    }
	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("ArryTheDog Software"));

	LoadStdProfileSettings(9);  // Load standard INI file options (including MRU)

	m_plistRecentWorkspaces = new CRecentFileList(	0,
													_T("Recent Workspace List"),
													_T("Workspace%d"),
													10);
	m_plistRecentWorkspaces->ReadList();

	m_pDocManager = new BXFileDialogDocManager;

	// Register the application's document templates.  Document templates
	// serve as the connection between documents, frame windows and views.
	//
	// This is the template for resource symbol files
	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_SYMBOL_FILE_TYPE,
		RUNTIME_CLASS(CResOrgSymbolsDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CResOrgSymbolsListView));
	AddDocTemplate(pDocTemplate);

	m_pHtmlDocTemplate = new CMultiDocTemplate(
		IDR_HTML_TYPE,
		RUNTIME_CLASS(CResOrgHtmlDoc),
		RUNTIME_CLASS(CChildFrame),
		RUNTIME_CLASS(CResOrgHtmlView));

	// Create the "Projects" document
	m_pProjectsDoc = new CResOrgAppProjectsDoc;
	ASSERT_KINDOF( CDocument, m_pProjectsDoc );

	// Create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
	{
		return FALSE;
	}
	m_pMainWnd = pMainFrame;

	// Initialize the cool menus...
	UINT nToolBars[] =	{
							IDR_MAINFRAME
						}; // can be many tool bars
		
	pMainFrame->InitializeMenu(	pDocTemplate,
								IDR_SYMBOL_FILE_TYPE,
								nToolBars,
								1,			
								IDR_MAINFRAME);
	
	pMainFrame->InitializeMenu(	m_pHtmlDocTemplate,
								IDR_HTML_TYPE,
								nToolBars,
								1,			
								IDR_MAINFRAME);
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(TRUE);

	// Read options from the registry
	Options.Initialise();

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Create splash window if not run silently
	if (cmdInfo.m_bShowSplash)
	{
		ShowSplashScreen();
	}
	// Dispatch commands specified on the command line
	if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
	{
		cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	}
	if (!ProcessShellCommand(cmdInfo))
	{
		return FALSE;
	}
	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(m_nCmdShow);
	pMainFrame->UpdateWindow();


	#ifdef _RESORG_EXPIRY_DATE
		::DoVersionExpiryCheck();
	#endif

	CString sAddInName;
	sAddInName.LoadString(IDS_RESORG_LONGNAME);

	CDSAddInLoader loader(sAddInName);
	if (!loader.IsLoaded() && loader.CanLoad() )
	{
		// If ResOrg hasn't been loaded before, work out default values
		// for the filename and description fields
		CNGSplitPath split(m_pszHelpFilePath);

		CString sFileName = split.GetDrive() +
							split.GetDirectory() +
							_T("ResOrgAddIn.dll");

		if (!::FileExists(sFileName) )
		{
			sFileName = _T("");
		}

		// If necessary, ask the user whether to load the Add-In
		if (!sFileName.IsEmpty() && Options.AskAboutLoadingAddIn() )
		{
			CResOrgAddInLoadPrompt dlg;
			if (IDYES == dlg.DoModal())
			{
				CString sDescription = loader.GetDescription();
				if (sDescription.IsEmpty())
				{
					sDescription.LoadString(IDS_RESORG_DESCRIPTION);
				}
				loader.SetDescription(sDescription);
				loader.SetPathName(sFileName);
				loader.Load(TRUE);
			}
			if (dlg.m_bDontAskAgain)
			{
				Options.AskAboutLoadingAddIn(FALSE);
			}
		}
	}
	if (Options.IsMailingListPromptEnabled() )
	{
		Options.EnableMailingListPrompt(FALSE);		// Only ask once

		if (IDYES == DoMailingListQuery())
		{
			::ShellExecute(	::GetDesktopWindow(),
							_T("open"),
							Options.GetMailingListURL(),
							NULL,
							NULL,
							SW_SHOWNORMAL);
		}
	}
	Options.DoVersionCheck();

	return TRUE;
}


/******************************************************************************
 *	Idle processing handler
 *
 ******************************************************************************/

BOOL CResOrgApp::OnIdle(LONG lCount) 
{
	// Call base class idle implementation first...
	BOOL bResult = CResOrgApp_BASE::OnIdle(lCount);

	// ...then do our stuff
	if ( (NULL != m_pwndSplash) && (NULL != m_pwndSplash->GetSafeHwnd()) )
	{
		if (::GetTickCount() - m_dwSplashTime > SPLASHWND_DURATION)
		{
			// Timeout expired, destroy the splash window
			KillSplashWnd();

			// NOTE: don't set bResult to FALSE,
			// (CResOrgApp_BASE::OnIdle may have returned TRUE)
		}
		else
		{

⌨️ 快捷键说明

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