📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "vchelper.h"
#include "topicview.h"
#include "helplistview.h"
#include "helpeditview.h"
#include "addtopic.h"
#include "vchelperdoc.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CCJFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CCJFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_FORMAT_FONT, OnFormatFont)
ON_COMMAND(ID_OPEN, OnOpen)
ON_COMMAND(ID_ADD_TOPIC, OnAddTopic)
ON_COMMAND(ID_FIND, OnFind)
ON_COMMAND(ID_ADD_FILE, OnAddFile)
//}}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 (CCJFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndCoolBar.Create(this,
WS_CHILD|WS_VISIBLE|WS_BORDER|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
RBS_TOOLTIPS|RBS_BANDBORDERS|RBS_VARHEIGHT))
{
TRACE0("Failed to create cool bar\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
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
EnableDockingSizeBar(CBRS_ALIGN_ANY);
m_menuManager.Install(this);
m_menuManager.LoadToolbar(IDR_MAINFRAME);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CCJFrameWnd::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
{
CCJFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CCJFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if (!m_wndSplitter1.CreateStatic(this, 1, 2))
{
TRACE0("Failed to create splitter1 window\n");
return FALSE;
}
// Outlook bar view.
if (!m_wndSplitter1.CreateView(0, 0, RUNTIME_CLASS(CTopicView),
CSize(170, 0), pContext))
{
TRACE0("Failed to create CTopicView\n");
return FALSE;
}
// "Flexible pane": The second pane may present its own
// splitter windows.
if(!m_wndSplitter2.CreateStatic(&m_wndSplitter1,
2,1,
WS_CHILD | WS_VISIBLE | WS_BORDER,
m_wndSplitter1.IdFromRowCol(0, 1)))
{
TRACE0("Failed to create splitter2 window\n");
return FALSE;
}
if (!m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CHelpListView),
CSize(0, 200), pContext))
{
TRACE0("Failed to create CHelpListView\n");
return FALSE;
}
if (!m_wndSplitter2.CreateView(1, 0, RUNTIME_CLASS(CHelpEditView),
CSize(0, 0), pContext))
{
TRACE0("Failed to create CHelpListView\n");
return FALSE;
}
return true;
}
CHelpListView* CMainFrame::GetListView()
{
CHelpListView *pview=DYNAMIC_DOWNCAST(CHelpListView,m_wndSplitter2.GetPane(0,0));
return pview;
}
CHelpEditView* CMainFrame::GetEditView()
{
CHelpEditView *pview=DYNAMIC_DOWNCAST(CHelpEditView,m_wndSplitter2.GetPane(1,0));
return pview;
}
CTopicView* CMainFrame::GetTreeView()
{
CTopicView *pview=DYNAMIC_DOWNCAST(CTopicView,m_wndSplitter1.GetPane(0,0));
return pview;
}
/*
void CMainFrame::OnAddFile()
{
CAddFileDlg addfiledlg;
if(!GetTreeView()->Search(addfiledlg.m_selid1,addfiledlg.m_selid2))
{
addfiledlg.m_selid1=addfiledlg.m_selid2=-1;
}
addfiledlg.DoModal();
GetListView()->OnChange();
}
void CMainFrame::OnFind()
{
CFindDlg finddlg;
if(finddlg.DoModal()==IDOK)
{
}
}
void CMainFrame::OnAddTopic()
{
CAddTopicDlg addtopicdlg;
addtopicdlg.DoModal();
GetTreeView()->ShowData();
}
*/
void CMainFrame::OnFormatFont()
{
GetEditView()->FormatFont();
}
void CMainFrame::HideList(BOOL frag)
{
int row;
#ifdef _AFXDLL
row=0;
#else
row=-10;
#endif
if(frag)
{
m_wndSplitter1.SetColumnInfo(0,row,row);
m_wndSplitter1.RecalcLayout();
m_wndSplitter2.SetRowInfo(0,row,row);
m_wndSplitter2.RecalcLayout();
}
else
{
m_wndSplitter1.SetColumnInfo(0,170,0);
m_wndSplitter1.RecalcLayout();
m_wndSplitter2.SetRowInfo(0,200,0);
m_wndSplitter2.RecalcLayout();
}
}
void CMainFrame::OnOpen()
{
if(theApp.OpenDb())
{
GetTreeView()->GetDocument()->UpdataDb();
GetTreeView()->ShowData();
GetListView()->m_pctrl->DeleteAllItems();
}
}
void CMainFrame::OnAddTopic()
{
GetTreeView()->AddTopic();
}
void CMainFrame::OnFind()
{
GetListView()->Find();
}
void CMainFrame::OnAddFile()
{
GetListView()->OnAddFile();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -