vicdoc.cpp
来自「本人买的<<VC++项目开发实例>>源代码配套光盘.」· C++ 代码 · 共 156 行
CPP
156 行
// VicDoc.cpp : implementation of the CVicDoc class
//
#include "stdafx.h"
#include "DBExp.h"
#include "VicDoc.h"
#include "mainfrm.h"
#include "aliasview.h"
#include "msg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CVicDoc
typedef LRESULT( CWnd::* WIN_MSG_HANDLER)(WPARAM, LPARAM);
IMPLEMENT_DYNCREATE(CVicDoc, CDocument)
BEGIN_MESSAGE_MAP(CVicDoc, CDocument)
//{{AFX_MSG_MAP(CVicDoc)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_DBEXP_DELETE_ALIAS, (WIN_MSG_HANDLER)OnAliasDelete)
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CVicDoc, CDocument)
//{{AFX_DISPATCH_MAP(CVicDoc)
DISP_FUNCTION(CVicDoc, "GetVersion", GetVersion, VT_BSTR, VTS_NONE)
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// Note: we add support for IID_IDBExp to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {21E91FB9-18AE-4E59-B77A-5E8275A26688}
static const IID IID_IDBExp =
{ 0x21e91fb9, 0x18ae, 0x4e59, { 0xb7, 0x7a, 0x5e, 0x82, 0x75, 0xa2, 0x66, 0x88 } };
BEGIN_INTERFACE_MAP(CVicDoc, CDocument)
INTERFACE_PART(CVicDoc, IID_IDBExp, Dispatch)
END_INTERFACE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CVicDoc construction/destruction
//##ModelId=3C37413C032C
CVicDoc::CVicDoc()
{
// TODO: add one-time construction code here
EnableAutomation();
AfxOleLockApp();
}
//##ModelId=3C37413C0368
CVicDoc::~CVicDoc()
{
AfxOleUnlockApp();
}
//##ModelId=3C37413C0336
BOOL CVicDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
m_AliasManager.LoadAllAliases();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CVicDoc serialization
//##ModelId=3C37413C034A
void CVicDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CVicDoc diagnostics
#ifdef _DEBUG
//##ModelId=3C37413C0372
void CVicDoc::AssertValid() const
{
CDocument::AssertValid();
}
//##ModelId=3C37413C037C
void CVicDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CVicDoc commands
//##ModelId=3C3968D003B9
CDBExpAliasManager& CVicDoc::get_AliasManager()
{
return m_AliasManager;
}
//##ModelId=3C41D2680307
BSTR CVicDoc::GetVersion()
{
CString strResult;
// TODO: Add your dispatch handler code here
strResult = "DBExplorer v1.0 draft 开发者 Victor Lee";
return strResult.AllocSysString();
}
/*这个函数的主要功能是用来维护结点删除后的AliasManager的维护工作
注意:它并不负责pNode结点的删除。
它的职能是删除在AliasManager链上的包含pNode指针的那个结点!!!
*/
//##ModelId=3CA0A1E301F4
LRESULT CVicDoc::OnAliasDelete(WPARAM pNode, LPARAM)
{
ASSERT(pNode);
CDBExpAlias *pAliasNode = (CDBExpAlias *)pNode;
//删除TreeCtrl上这个结点
CMainFrame *pMainWnd = (CMainFrame *)AfxGetMainWnd();
PostMessage(pMainWnd->GetLeftPane()->m_hWnd, WM_DELETE_HITEM, (WPARAM)pAliasNode->Get_hItem(), 0);
//压缩AliasManager中的这个结点
m_AliasManager.RevokeAliasNode((CDBExpAlias *)pNode);
return 0;
}
//##ModelId=3CC835670135
LRESULT CVicDoc::OnOptionDlgApply(WPARAM wParam, LPARAM lParam)
{
//AfxMessageBox("OnOptionDlgApply");
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?