📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "DAOQry.h"
#include "DaoListView.h"
#include "MainFrm.h"
#include "OptionsDlg.h"
#include "DAOQryDoc.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_VIEW_OPTIONS, OnViewOptions)
//}}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
}
//使工具条可以停靠
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
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
//切分视图成1 row X 2 columns
if (!m_Splitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
//左视
if (!m_Splitter.CreateView(0, 0,
pContext->m_pNewViewClass, CSize(200, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
//右视
if (!m_Splitter.CreateView(0, 1,
RUNTIME_CLASS(CDaoListView), CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
//设置初始活动视图
SetActiveView((CView*)m_Splitter.GetPane(0,1));
return TRUE;
}
//设置是否显示系统对象和是否提示警告信息等选项开关
void CMainFrame::OnViewOptions()
{
CPropertySheet propSheet(_T("DaoView - Options"));
COptionsDlg pageOptions;
propSheet.AddPage(&pageOptions);
CDAOQryApp* pApp = (CDAOQryApp *)AfxGetApp();
pageOptions.m_bShowWarnings = pApp->m_bShowWarnings;
pageOptions.m_bShowSystemObjects = pApp->m_bShowSystemObjects;
pageOptions.m_bOpenODBC= pApp->m_bOpenODBC;
pageOptions.m_nMaxRecords= pApp->m_nMaxRecords;
if (propSheet.DoModal() == IDOK)
{
BOOL bRebuildList = FALSE;
if (pApp->m_bShowSystemObjects != pageOptions.m_bShowSystemObjects)
bRebuildList = TRUE;
pApp->m_bShowSystemObjects = pageOptions.m_bShowSystemObjects;
if (bRebuildList)
((CDAOQryDoc*) GetActiveDocument())->RefreshViews();
pApp->m_bShowWarnings = pageOptions.m_bShowWarnings;
pApp->m_bOpenODBC = pageOptions.m_bOpenODBC;
pApp->m_nMaxRecords = pageOptions.m_nMaxRecords;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -