📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "Edit3DM.h"
#include "MainFrm.h"
#include "edit3dmdoc.h"
#include "childoglview.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)
ON_WM_CREATE()
ON_COMMAND(ID_CHILDOGLVIEWA, OnChildoglviewa)
ON_UPDATE_COMMAND_UI(ID_CHILDOGLVIEWA, OnUpdateChildoglviewa)
ON_COMMAND(ID_CHILDOGLVIEWB, OnChildoglviewb)
ON_UPDATE_COMMAND_UI(ID_CHILDOGLVIEWB, OnUpdateChildoglviewb)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_pMainView = NULL;
}
CMainFrame::~CMainFrame()
{
if(m_pMainView != NULL)
m_pMainView = NULL;
}
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
}
//To create dock view bar
CString sTitle;
sTitle.Format(_T("视图A"));
if (!m_wndChildOGLView1.Create(this,
RUNTIME_CLASS (CChildOGLView),
(CCreateContext *)(lpCreateStruct->lpCreateParams),
sTitle, WS_CHILD | WS_VISIBLE | CBRS_TOP,
AFX_IDW_CONTROLBAR_FIRST + 33 + 1))
{
TRACE0("Failed to create ViewBar\n");
return -1; // fail to create
}
sTitle.Format(_T("视图B"));
if (!m_wndChildOGLView2.Create(this,
RUNTIME_CLASS (CChildOGLView),
(CCreateContext *)(lpCreateStruct->lpCreateParams),
sTitle, WS_CHILD | WS_VISIBLE | CBRS_TOP,
AFX_IDW_CONTROLBAR_FIRST + 33 + 2))
{
TRACE0("Failed to create ViewBar\n");
return -1; // fail to create
}
//Let the dock view bar to be sizable
// CBRS_SIZE_DYNAMIC allows the bar to be resized when floating
m_wndChildOGLView1.SetBarStyle(m_wndChildOGLView1.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndChildOGLView2.SetBarStyle(m_wndChildOGLView2.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
//Enable Docking
EnableDocking(CBRS_ALIGN_ANY);
m_wndChildOGLView1.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
m_wndChildOGLView2.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
//To put the two child OGL view on the same column
DockControlBar(&m_wndChildOGLView1, AFX_IDW_DOCKBAR_RIGHT);
//DockControlBar(&m_wndChildOGLView2, AFX_IDW_DOCKBAR_RIGHT);
RecalcLayout();
CRect rBar;
m_wndChildOGLView1.GetWindowRect(rBar);
rBar.OffsetRect(0, 1);
DockControlBar(&m_wndChildOGLView2, AFX_IDW_DOCKBAR_RIGHT, rBar);
AssignViewID();
// 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;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
void CMainFrame::AssignViewID()
{
CEdit3DMDoc* pdoc = (CEdit3DMDoc*)m_pMainView->GetDocument();
if(pdoc)
{
POSITION pos = pdoc->GetFirstViewPosition();
CView* pview;
int tempid = 1;
while (pos != NULL)
{
pview = pdoc->GetNextView(pos);
if (pview->IsKindOf(RUNTIME_CLASS(CChildOGLView)))
{
CChildOGLView* pchildview = (CChildOGLView*)pview;
pchildview->m_ViewID = tempid;
tempid += 1;
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnChildoglviewa()
{
// TODO: Add your command handler code here
BOOL bShow = m_wndChildOGLView1.IsVisible();
ShowControlBar(&m_wndChildOGLView1, !bShow, FALSE);
}
void CMainFrame::OnUpdateChildoglviewa(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndChildOGLView1.IsVisible());
}
void CMainFrame::OnChildoglviewb()
{
// TODO: Add your command handler code here
BOOL bShow = m_wndChildOGLView2.IsVisible();
ShowControlBar(&m_wndChildOGLView2, !bShow, FALSE);
}
void CMainFrame::OnUpdateChildoglviewb(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndChildOGLView2.IsVisible());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -