📄 resorgaddinapp.cpp
字号:
RUNTIME_CLASS(CResOrgSymbolsDoc),
RUNTIME_CLASS(CChildFrame), // Custom MDI child frame
RUNTIME_CLASS(CResOrgSymbolsListView) );
m_pMainDocTemplate->m_bAutoDelete = TRUE;
AddDocTemplate(m_pMainDocTemplate);
m_pHtmlDocTemplate = new CMultiDocTemplate(
IDR_HTML_TYPE,
RUNTIME_CLASS(CResOrgHtmlDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CHtmlView) );
// Create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
ASSERT_VALID(pMainFrame);
if (NULL != pMainFrame)
{
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
{
return;
}
AfxGetApp()->m_pMainWnd = pMainFrame;
// Initialize the cool menus...
UINT nToolBars[] =
{
IDR_MAINFRAME
}; // ...can be many toolbars...
pMainFrame->InitializeMenu( m_pMainDocTemplate,
IDR_SYMBOL_FILE_TYPE,
nToolBars,
1,
IDR_MAINFRAME);
pMainFrame->InitializeMenu( m_pHtmlDocTemplate,
IDR_HTML_TYPE,
nToolBars,
1,
IDR_MAINFRAME);
// Enable drag/drop open
pMainFrame->DragAcceptFiles();
// Read options from the registry, and kick off the
// version check (if appropriate)
Options.Initialise();
if (Options.IsMailingListPromptEnabled() )
{
Options.EnableMailingListPrompt(FALSE); // Only ask once
if (IDYES == DoMailingListQuery())
{
::ShellExecute( ::GetDesktopWindow(),
_T("open"),
Options.GetMailingListURL(),
NULL,
NULL,
SW_SHOWNORMAL);
}
}
Options.DoVersionCheck();
}
}
void CResOrgAddInApp::OnDisconnection(void)
{
if (NULL != m_pMainWnd)
{
if (::IsWindow(m_pMainWnd->m_hWnd))
{
m_pMainWnd->DestroyWindow();
}
delete m_pMainWnd;
}
if (NULL != m_pDocManager)
{
// Trick CWinApp into thinking we're an application (exe) to
// clear up static CDocManager objects:
//
// CDocManager::pStaticList
// CDocManager::pStaticDocManager
//
// Look at the CWinApp destructor in appcore.cpp for more details.
//
// Thanks to Gavin Jerman (gavin.jerman@zurich.co.uk) for this fix
AfxGetModuleState()->m_bDLL = FALSE;
delete m_pDocManager;
m_pDocManager = NULL;
}
}
BOOL CResOrgAddInApp::OnIdle(LONG lCount)
{
return CResOrgAddInApp_BASE::OnIdle(lCount);
}
void CResOrgAddInApp::OnFileNew(void)
{
CResOrgAddInApp_BASE::OnFileNew();
}
int CResOrgAddInApp::ExitInstance(void)
{
// If a version check is running, Wait until it finishes
// before exiting (by now the main window has gone)
Options.OnExit();
_Module.Term();
return CResOrgAddInApp_BASE::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgAddInApp implementation
void CResOrgAddInApp::OpenHtmlView( const CString& sTitle,
const CString& sURL)
{
ASSERT(NULL != m_pHtmlDocTemplate);
if (NULL != m_pHtmlDocTemplate)
{
CDocument* pDoc = m_pHtmlDocTemplate->CreateNewDocument();
if (NULL != pDoc)
{
pDoc->SetTitle(sTitle);
CFrameWnd* pFrame = m_pHtmlDocTemplate->CreateNewFrame(pDoc, NULL);
if (NULL == pFrame)
{
TRACE0("Warning: failed to create new frame.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE, MB_OK | MB_ICONSTOP);
return; // command failed
}
m_pHtmlDocTemplate->InitialUpdateFrame(pFrame, pDoc);
CView* pView = pFrame->GetActiveView();
if (NULL != pView)
{
((CHtmlView*)pView)->Navigate2(sURL, 0);
}
}
}
}
BOOL CResOrgAddInApp::CloseOpenDocuments(void)
{
BOOL bResult = TRUE;
CNGDocEnumerator docs;
CDocument* pDoc = NULL;
do
{
pDoc = docs.GetNextDoc();
if (NULL != pDoc)
{
if (pDoc->SaveModified() )
{
pDoc->OnCloseDocument();
}
else
{
bResult = FALSE;
break;
}
}
} while (NULL != pDoc);
if (NULL != m_pHtmlDocTemplate)
{
POSITION pos = m_pHtmlDocTemplate->GetFirstDocPosition();
while (NULL != pos)
{
CDocument* pDoc = m_pHtmlDocTemplate->GetNextDoc(pos);
if (NULL != pDoc)
{
pDoc->OnCloseDocument();
}
}
}
return bResult;
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgAddInApp message handlers
void CResOrgAddInApp::OnCmdResOrgWebsite(void)
{
CString sTitle;
sTitle.LoadString(IDP_RESORG_WEB_TITLE);
OpenHtmlView(sTitle, Options.GetWebURL() );
}
void CResOrgAddInApp::OnCmdResOrgFAQ(void)
{
CString sTitle;
sTitle.LoadString(IDP_RESORG_FAQ_TITLE);
OpenHtmlView(sTitle, Options.GetFaqURL() );
}
void CResOrgAddInApp::OnUpdateResOrgFAQ(CCmdUI* pCmdUI)
{
pCmdUI->Enable( !Options.GetFaqURL().IsEmpty() );
}
void CResOrgAddInApp::OnCmdResOrgDiscussionBoard(void)
{
CString sTitle;
sTitle.LoadString(IDP_RESORG_DISCUSSIONS_TITLE);
OpenHtmlView(sTitle, Options.GetDiscussionBoardURL() );
}
void CResOrgAddInApp::OnUpdateResOrgDiscussionBoard(CCmdUI* pCmdUI)
{
pCmdUI->Enable( !Options.GetDiscussionBoardURL().IsEmpty() );
}
void CResOrgAddInApp::OnCmdResOrgKnownBugs(void)
{
CString sTitle;
sTitle.LoadString(IDP_RESORG_KNOWN_BUGS_TITLE);
OpenHtmlView(sTitle, Options.GetKnownBugsURL() );
}
void CResOrgAddInApp::OnUpdateResOrgKnownBugs(CCmdUI* pCmdUI)
{
pCmdUI->Enable( !Options.GetKnownBugsURL().IsEmpty() );
}
void CResOrgAddInApp::OnCmdResOrgMailingList(void)
{
CString sTitle;
sTitle.LoadString(IDP_RESORG_MAILING_LIST);
OpenHtmlView(sTitle, Options.GetMailingListURL() );
}
void CResOrgAddInApp::OnUpdateResOrgMailingList(CCmdUI* pCmdUI)
{
pCmdUI->Enable( !Options.GetMailingListURL().IsEmpty() );
}
// App command to run the dialog
void CResOrgAddInApp::OnCmdAbout(void)
{
CResOrgAboutBox aboutDlg;
aboutDlg.DoModal();
}
void CResOrgAddInApp::OnCmdOptions(void)
{
Options.Configure();
}
void CResOrgAddInApp::OnCmdWindowCloseAll(void)
{
CloseOpenDocuments();
}
void CResOrgAddInApp::OnUpdateWindowCloseAll(CCmdUI* pCmdUI)
{
int nOpenDocs = m_pDocManager->GetOpenDocumentCount();
if (0 == nOpenDocs)
{
POSITION pos = m_pHtmlDocTemplate->GetFirstDocPosition();
if (NULL != pos)
{
if (NULL != m_pHtmlDocTemplate->GetNextDoc(pos) )
{
nOpenDocs++; // Force command to be available
}
}
}
pCmdUI->Enable(nOpenDocs > 0);
}
/////////////////////////////////////////////////////////////////////////////
// CResOrgAddInApp operations
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -