📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "SuperMap Example.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)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_COMMAND(ID_SHOWWKS, OnShowWksMng)
ON_UPDATE_COMMAND_UI(ID_SHOWWKS, OnUpdateWksMng)
//}}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
}
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
}
//创建工作空间
if(!m_SuperWorkspace.Create("workspace", WS_CHILD|WS_VISIBLE, CRect(0, 0, 10, 10),
this, 1, NULL, false, NULL))
{
TRACE0("Failed to create SuperWorkspace\n");
return -1;
}
m_SuperTopo.Create("Topo",WS_CHILD|WS_VISIBLE, CRect(10, 10, 20, 20),
this, 2, NULL, false, NULL);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_MyDlgBar.Create(this,IDD_MYDLGBAR, CBRS_RIGHT|CBRS_TOOLTIPS|CBRS_FLYBY,IDD_MYDLGBAR);
m_MyDlgBar.SetWindowText("数据管理器");
m_MyDlgBar.EnableDocking(CBRS_ALIGN_RIGHT);
m_MyDlgBar.m_SuperWksMng.Connect(m_SuperWorkspace.GetHandle());
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
DockControlBar(&m_MyDlgBar);
CFrameWnd::SetTitle("SuperMap Objects 范例程序");
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO:取消窗口的最大化按钮
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
| WS_SYSMENU | WS_MINIMIZEBOX;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// 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::PostNcDestroy()
{
CFrameWnd::PostNcDestroy();
}
void CMainFrame::OnDestroy()
{
m_SuperWorkspace.Close();//关闭工作空间
CMainFrame::OnDestroy();
}
void CMainFrame::OnFileOpen()
{
//打开SuperMap的SDB数据源
CFileDialog dlg(true, NULL, NULL, OFN_OVERWRITEPROMPT, "SuperMap SDB File(*.sdb)|*.sdb", NULL);
if(dlg.DoModal() == IDOK)
{
CSuperMapExampleApp *pApp = (CSuperMapExampleApp *)::AfxGetApp();
pApp->OpenDocumentFile(dlg.m_ofn.lpstrFile);
}
}
void CMainFrame::OnShowWksMng()
{
//是否显示数据管理器
if(!m_MyDlgBar.IsWindowVisible()){
DockControlBar(&(m_MyDlgBar),AFX_IDW_DOCKBAR_RIGHT);
ShowControlBar(&(m_MyDlgBar), TRUE, FALSE);
}
else{
ShowControlBar(&(m_MyDlgBar), FALSE, FALSE);
}
RecalcLayout();
}
void CMainFrame::OnUpdateWksMng(CCmdUI* pCmdUI)
{
//改变工具条的状态
pCmdUI->SetCheck(m_MyDlgBar.IsWindowVisible());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -