📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MFCD3D.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
ON_UPDATE_COMMAND_UI(ID_INDICATOR_DEVICE, OnUpdateDeviceStats)
ON_UPDATE_COMMAND_UI(ID_INDICATOR_FPS, OnUpdateFrameStats)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_DEVICE,
ID_INDICATOR_FPS
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// size the status bar panels
m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_DEVICE),
ID_INDICATOR_DEVICE,
SBPS_NORMAL,
428);
m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(ID_INDICATOR_FPS),
ID_INDICATOR_FPS,
SBPS_NORMAL,
50);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
cs.style &= ~FWS_ADDTOTITLE;
return TRUE;
}
// status bar pane updater
void CMainFrame::UpdateStatusBar(DWORD dwPaneID, LPCTSTR lpszText)
{
CString* psText;
// force UI updates...
switch (dwPaneID)
{
case ID_INDICATOR_DEVICE: psText = &m_sDeviceStats; break;
case ID_INDICATOR_FPS: psText = &m_sFrameStats; break;
default:
return;
}
// with any extra formatting here.
psText->Format(" %s", lpszText);
// uncomment the next section for dynamic (content-based) pane resizing; this
// saves guessing the required pane sizes, but it can be annoying if the text
// extent of psText varies frequently on broad ranges...
/* CFont* pFont = m_wndStatusBar.GetFont();
CFont* pOldFont = NULL;
// get a client DC for dynamic resizing
CClientDC dc((CWnd*)&m_wndStatusBar);
if (pFont != NULL)
pOldFont = dc.SelectObject(pFont);
// get the text extent
CSize size = dc.GetTextExtent(*psText);
// done with DC objects and the DC
dc.SelectObject(pOldFont);
ReleaseDC(&dc);
// actual horizontal resize, with some extra trailing space
m_wndStatusBar.SetPaneInfo(m_wndStatusBar.CommandToIndex(dwPaneID), dwPaneID, SBPS_NORMAL, size.cx + 3);
*/
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnUpdateDeviceStats(CCmdUI* pCmdUI)
{
pCmdUI->Enable(); pCmdUI->SetText(m_sDeviceStats);
}
void CMainFrame::OnUpdateFrameStats(CCmdUI* pCmdUI)
{
pCmdUI->Enable(); pCmdUI->SetText(m_sFrameStats);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -