📄 mainfrms.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrameS class
//
#include "stdafx.h"
#include "MainFrmS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrameS
IMPLEMENT_DYNAMIC(CMainFrameS, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrameS, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrameS)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrameS construction/destruction
CMainFrameS::CMainFrameS(DRAWFUN pDraw,CWnd*pOldW,CWnd* pCallW,BOOL bDirect,LPCTSTR stTitle)
{
// TODO: add member initialization code here
Draw=pDraw;
pOldWnd=pOldW;
pCallWnd=pCallW;
bDirectPrint=bDirect;
CString ss;
if(stTitle!=NULL)
ss=_T(stTitle);
else
{
pOldW->GetWindowText(ss);
if(!ss.IsEmpty())
ss=ss+_T(" (预览)");
else
ss=ss+_T("打印预览");
}
if(!Create(NULL,ss,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,CRect(200,200,500,500)))
TRACE0("Failed to create view window\n");
}
CMainFrameS::~CMainFrameS()
{
pOldWnd->ShowWindow(SW_SHOW);
pCallWnd->SetActiveWindow();
pCallWnd->SendMessage(WM_PRINTEND,bDirectPrint);
}
int CMainFrameS::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CWrapperView);
context.m_pCurrentFrame = this;
context.m_pCurrentDoc = NULL;
context.m_pLastView = NULL;
m_pView = STATIC_DOWNCAST(CWrapperView, CreateView(&context)); //CreateView(&context);
if(m_pView != NULL)
{
if(!bDirectPrint)
m_pView->ShowWindow(SW_SHOW);
SetActiveView(m_pView);
}
SetIcon(pOldWnd->GetIcon(FALSE),FALSE);
SetIcon(pOldWnd->GetIcon(TRUE),TRUE);
ShowWindow(SW_MAXIMIZE);
CWinApp *pApp=AfxGetApp();
pApp->m_pMainWnd=this;
if(bDirectPrint)
{
m_pView->SendMessage(WM_COMMAND, ID_FILE_PRINT);
}
else
{
m_pView->OnFilePrintPreview(this);
pOldWnd->ShowWindow(SW_HIDE);
}
return 0;
}
BOOL CMainFrameS::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrameS diagnostics
#ifdef _DEBUG
void CMainFrameS::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrameS::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrameS message handlers
BOOL CMainFrameS::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// let the view have first crack at the command
if (m_pView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// otherwise, do default handling
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -