📄 leftbar.cpp
字号:
// LeftBar.cpp : implementation file
//
#include "stdafx.h"
#include "Access.h"
#include "LeftBar.h"
#include "AccessDoc.h"
#include "AccessView.h"
#include "Ado.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLeftBar
CLeftBar::CLeftBar()
{
}
CLeftBar::~CLeftBar()
{
}
BEGIN_MESSAGE_MAP(CLeftBar, CCoolControlBar)
//{{AFX_MSG_MAP(CLeftBar)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLeftBar message handlers
int CLeftBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CCoolControlBar::OnCreate(lpCreateStruct) == -1)
return -1;
m_ctrlTree.Create(WS_CHILD | WS_VISIBLE | TVS_LINESATROOT | TVS_HASBUTTONS
| TVS_HASLINES,
CRect(0, 0, 0, 0), this, 0);
m_imagelist.Create(IDB_LEFTBAR, 12, 12, RGB(255, 255, 255));
m_ctrlTree.SetImageList(&m_imagelist, TVSIL_NORMAL);
return 0;
}
void CLeftBar::OnSize(UINT nType, int cx, int cy)
{
CCoolControlBar::OnSize(nType, cx, cy);
CRect rect;
this->GetClientRect(&rect);
m_ctrlTree.MoveWindow(rect);
}
BOOL CLeftBar::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
CAccessDoc* CLeftBar::GetDocument()
{
CFrameWnd* pframe = (CFrameWnd*)GetParentFrame();
ASSERT(pframe != NULL);
CView* pview = (CView*)pframe->GetActiveView();
ASSERT(pview != NULL);
CDocument* pdoc = pview->GetDocument();
ASSERT(pdoc != NULL);
ASSERT(pdoc->IsKindOf(RUNTIME_CLASS(CAccessDoc)));
return (CAccessDoc*)pdoc;
}
void CLeftBar::InitTree()
{
CAdoRecordSet rset;
_bstr_t Value;
CString strTablename = "";
HTREEITEM item = TVI_ROOT;
try
{
if (GetDocument()->m_adoConnection.GetConnection()->State != adStateOpen) return;
m_ctrlTree.DeleteAllItems();
rset = GetDocument()->m_adoConnection.OpenSchema (adSchemaColumns);
while (!rset.IsEOF())
{
CString strValue;
rset.GetValueString(strValue, "TABLE_NAME");
if (strValue != strTablename)
{
strTablename = strValue;
item = m_ctrlTree.InsertItem((LPCTSTR)strTablename, 1, 1);
}
Value = rset.GetFields()->Item[L"COLUMN_NAME"]->Value;
m_ctrlTree.InsertItem((LPCTSTR)Value, 2, 2, item);
rset.MoveNext();
}
}
catch(_com_error e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -