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

📄 resorgapp.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			if (dwUseableVer >= 0x501)
			{
				// Use the VS.NET visual style on WinXP and later
				static_cast<BXFileDialogDocManager*>(m_pDocManager)->SetAppearance(BXFileDialog::APPEARANCE_VSDOTNET);
			}
		}
	#endif

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

	// Use Office XP style menus if selected
	CCJMenu::SetMenuDrawMode(Options.UseXpStyleMenus() ? CCJMenu_DRAWMODE_XP : CCJMenu_DRAWMODE_ORIGINAL);

	// 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(CResOrgMDIChildSplitWnd),		// custom MDI child frame
		RUNTIME_CLASS(CResOrgSymbolsListView) );

	AddDocTemplate(pDocTemplate);

	m_pMultiSymbolFileTemplate = new CMultiDocTemplate(
		IDR_SYMBOL_FILE_TYPE,
		RUNTIME_CLASS(CResOrgSymbolsDocMultiFile),
		RUNTIME_CLASS(CResOrgMDIChildSplitWnd),		// custom MDI child frame
		RUNTIME_CLASS(CResOrgSymbolsListView) );

	m_pHtmlDocTemplate = new CMultiDocTemplate(
		IDR_HTML_TYPE,
		RUNTIME_CLASS(CResOrgHtmlDoc),
		RUNTIME_CLASS(CResOrgMDIChildWnd),
		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;
	}

	pMainFrame->SetTitle(m_pszAppName);
	pMainFrame->SetWindowText(m_pszAppName);

	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_pMultiSymbolFileTemplate,
								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);

	// 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

	#if _MSC_VER < 1300		// The VC7 build of the app can't load the corresponding add-in
		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);
				}
			}
		}
	#endif

	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);

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

			// NOTE: don't set bResult to FALSE,
			// (CResOrgApp_BASE::OnIdle may have returned TRUE)
		}
		else
		{
			// Check again later...
			bResult = TRUE;
		}
	}
#endif
	return bResult;
}


/******************************************************************************
 *	Destroy the splash window if a keypress or mouse button event is detected
 *
 ******************************************************************************/

BOOL CResOrgApp::PreTranslateMessage(MSG* pMsg) 
{
	BOOL bResult = CResOrgApp_BASE::PreTranslateMessage(pMsg);

	if ( (NULL != m_pwndSplash) &&
		(NULL != m_pwndSplash->GetSafeHwnd()) &&
		(WM_KEYDOWN == pMsg->message ||
		 WM_SYSKEYDOWN == pMsg->message ||
		 WM_LBUTTONDOWN == pMsg->message ||
		 WM_RBUTTONDOWN == pMsg->message ||
		 WM_MBUTTONDOWN == pMsg->message ||
		 WM_NCLBUTTONDOWN == pMsg->message ||
		 WM_NCRBUTTONDOWN == pMsg->message ||
		 WM_NCMBUTTONDOWN == pMsg->message ))
	{
		KillSplashScreen();
	}
	return bResult;
}


void CResOrgApp::WinHelp(DWORD dwData, UINT nCmd)
{
	if (m_bHelpMode)
	{
		CWnd* pMainWnd = AfxGetMainWnd();
		ASSERT_VALID(pMainWnd);

		// return global app help mode state to FALSE (backward compatibility)
		m_bHelpMode = FALSE;
		pMainWnd->PostMessage(WM_KICKIDLE); // trigger idle update

		pMainWnd->WinHelp(dwData, HELP_CONTEXTPOPUP);
	}
	else
	{
		CResOrgApp_BASE::WinHelp(dwData, nCmd);
	}
}


int CResOrgApp::ExitInstance(void)
{
	// If a version check is running, Wait until it finishes
	// before exiting (by now the main window has gone)
	Options.OnExit();

	int nResult = CResOrgApp_BASE::ExitInstance();

	if (NULL != m_plistRecentWorkspaces)
	{
		// Write the workspace MRU list back to the registry
		m_plistRecentWorkspaces->WriteList();
	}
	return nResult;
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgApp operations

BOOL CResOrgApp::OpenWorkspace(const CString& sPathName)
{
	if (DoCloseAllWindowsQuery() && m_pProjectsDoc->OnOpenDocument(sPathName) )
	{
		AddToRecentWorkspacesList(sPathName);

		CMainFrame* pMainFrame = (CMainFrame*)m_pMainWnd;
		pMainFrame->ShowWorkspace(TRUE);

		m_pProjectsDoc->UpdateAllViews(NULL, SHOW_WORKSPACE);

		return TRUE;
	}
	return FALSE;
}


BOOL CResOrgApp::CloseWorkspace(void)
{
	if (DoCloseAllWindowsQuery() )
	{
		CMainFrame* pMainFrame = (CMainFrame*)m_pMainWnd;

		if (Options.AutoHideWorkspace() )
		{
			pMainFrame->ShowWorkspace(FALSE);
		}

		m_pProjectsDoc->UpdateAllViews(NULL, CLEAR_WORKSPACE);
		m_pProjectsDoc->DeleteContents();
	}
	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgApp implementation

void CResOrgApp::AddToRecentWorkspacesList(LPCTSTR lpszPathName)
{
	ASSERT_VALID(this);
	ASSERT(lpszPathName != NULL);
	ASSERT(AfxIsValidString(lpszPathName));

	if (NULL != m_plistRecentWorkspaces)
	{
		m_plistRecentWorkspaces->Add(lpszPathName);
	}
}


/////////////////////////////////////////////////////////////////////////////
// CResOrgApp message handlers

void CResOrgApp::OnCmdOpenWorkspace(void) 
{
	// Browse for the workspace (.dsw) file
	#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_WORKSPACES_EXT),	// Default extension
							NULL,												// Default filename
							OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST,				// Flags
							CString( (LPCTSTR)IDS_FILE_FILTER_WORKSPACES),		// 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();

		OpenWorkspace(sPathName);
	}
}


void CResOrgApp::OnCmdCloseWorkspace(void) 
{
	CloseWorkspace();
}


void CResOrgApp::OnUpdateCloseWorkspace(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( m_pProjectsDoc->IsWorkspaceOpen() );
}


BOOL CResOrgApp::OnCmdOpenRecentWorkspace(UINT nID)
{
	ASSERT_VALID(this);
	ASSERT(m_plistRecentWorkspaces != NULL);

	ASSERT(nID >= ID_WORKSPACE_MRU_FILE1);
	ASSERT(nID < ID_WORKSPACE_MRU_FILE1 + (UINT)m_plistRecentWorkspaces->GetSize());
	int nIndex = nID - ID_WORKSPACE_MRU_FILE1;

	if (!(*m_plistRecentWorkspaces)[nIndex].IsEmpty() )
	{
		TRACE2("MRU: open workspace (%d) '%s'.\n", (nIndex) + 1,
				(LPCTSTR)(*m_plistRecentWorkspaces)[nIndex]);

		if (!OpenWorkspace( (*m_plistRecentWorkspaces)[nIndex]) )
		{
			m_plistRecentWorkspaces->Remove(nIndex);
		}
	}
	return TRUE;
}


void CResOrgApp::OnUpdateRecentWorkspaceMenu(CCmdUI* pCmdUI)
{
	ASSERT_VALID(this);

	BOOL bEnable = FALSE;

	// The code below adds the workspaces MRU list to the
	// "Recent Workspaces" popup menu. Because the CMenu
	// pointer in the CCmdUI object we've been passed is
	// the root of the submenu, we need to replace it with
	// the first entry in the submenu, or the entries will
	// be added to the file menu itself (which causes a
	// conflict in the accelerator keys assigned to the two
	// MRU lists...)
	if (NULL != pCmdUI->m_pMenu)
	{
		CMenu* pSubMenu = NULL;
		pSubMenu = pCmdUI->m_pSubMenu;
/*		for (UINT n = 0; n < pCmdUI->m_pMenu->GetMenuItemCount(); n++)
		{
			CMenu* pMenu = pCmdUI->m_pMenu->GetSubMenu(n);
			if ( (NULL != pMenu) && (ID_WORKSPACE_MRU_FILE1 == pMenu->GetMenuItemID(0) ) )
			{
				pSubMenu = pMenu;
				break;
			}
		}
*/
		if (NULL != pSubMenu)
		{
			if (NULL != m_plistRecentWorkspaces)
			{
				int nSize = m_plistRecentWorkspaces->GetSize();
				if (nSize > 0)
				{
					for (int i = 0; i < nSize; i++)
					{
						if ((*m_plistRecentWorkspaces)[i].GetLength() > 0)
						{
							pCmdUI->m_pMenu = pSubMenu;
							m_plistRecentWorkspaces->UpdateMenu(pCmdUI);
							bEnable = TRUE;
							break;
						}
					}
				}
			}
			if (!bEnable)
			{
				// No MRU workspaces - so disable entry
				pSubMenu->EnableMenuItem(	ID_WORKSPACE_MRU_FILE1,
											MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);  
//				pCmdUI->m_pMenu->EnableMenuItem(	0,
//													MF_BYPOSITION | MF_DISABLED | MF_GRAYED);  
			}
		}
	}
}


// App command to run the dialog
void CResOrgApp::OnCmdAbout(void)
{
	CResOrgAboutBox aboutDlg;

	aboutDlg.DoModal();
}

⌨️ 快捷键说明

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