📄 globalmfchelperfunc.cpp
字号:
#include <afxwin.h>
#include "GlobalMFCHelperFunc.h"
#include "RemoteAdminView.h"
#include "MachineView.h"
#include "RemoteAdminDoc.h"
#include "MainFrame.h"
#include "RemoteAdmin.h"
CRemoteAdminDoc* MFC_DocView::GetAppDocument()
{
CDocManager* pDocManager = ::AfxGetApp()->m_pDocManager;
// As only one document template exits , we can avoid the check, as to at
// which position in the template list our document template is stored
// We know it is at the first position.
POSITION posDocTemplate = pDocManager->GetFirstDocTemplatePosition();
CSingleDocTemplate* pDocTemplate = static_cast<CSingleDocTemplate*>(pDocManager->GetNextDocTemplate(posDocTemplate));
POSITION posDoc = pDocTemplate->GetFirstDocPosition();
CRemoteAdminDoc* pDoc = static_cast<CRemoteAdminDoc*>(pDocTemplate->GetNextDoc(posDoc));
ASSERT_VALID(pDoc);
ASSERT_KINDOF(CRemoteAdminDoc, pDoc);
return pDoc;
}
CRemoteAdminView* MFC_DocView::GetRemoteAdminView()
{
CRemoteAdminDoc* pDoc = MFC_DocView::GetAppDocument();
POSITION pos = pDoc->GetFirstViewPosition();
CView* t_pView = NULL;
while(pos != NULL)
{
t_pView = pDoc->GetNextView(pos);
if(t_pView->IsKindOf(RUNTIME_CLASS(CRemoteAdminView)))
{
return static_cast<CRemoteAdminView*>(t_pView);
}
}
// Could not get the Remote Admin View
ASSERT(NULL);
return NULL;
}
CMachineView* MFC_DocView::GetMachineView()
{
CRemoteAdminDoc* pDoc = MFC_DocView::GetAppDocument();
POSITION pos = pDoc->GetFirstViewPosition();
CView* t_pView = NULL;
while(pos != NULL)
{
t_pView = pDoc->GetNextView(pos);
if(t_pView->IsKindOf(RUNTIME_CLASS(CMachineView)))
{
return (static_cast<CMachineView*>(t_pView));
}
}
// Could not get the Machine View
ASSERT(NULL);
return NULL;
}
CMainFrame* MFC_DocView::GetMainFrame()
{
CMainFrame* pMainFrame = static_cast<CMainFrame*>(::AfxGetMainWnd());
ASSERT(pMainFrame);
ASSERT_KINDOF(CMainFrame, pMainFrame);
return pMainFrame;
}
/* Helps in removing the casting problem while using AfxGetApp(), as it returns a (CWinApp*)
not a (CRemoteAdminApp*). So we can use the application pointer directly. */
CRemoteAdminApp* MFC_DocView::GetApp()
{
CRemoteAdminApp* pApp = static_cast<CRemoteAdminApp*>(::AfxGetApp());
ASSERT(pApp);
/* Can't use ASSERT_KINDOF as the CRamoteAdminApp class is not built with
the macros DELARE_DYNAMIC() or DECALRE_SERIAL() */
// ASSERT_KINDOF(CRemoteAdminApp, pApp);
return pApp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -