📄 leftview.cpp
字号:
// LeftView.cpp : implementation of the CLeftView class
//
#include "stdafx.h"
#include "CisoCA.h"
#include "CisoCADoc.h"
#include "LeftView.h"
#include "CisoCA.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CInfoReport InfoReport;
extern DWORD dwMoudleID;
/////////////////////////////////////////////////////////////////////////////
// CLeftView
IMPLEMENT_DYNCREATE(CLeftView, CTreeView)
BEGIN_MESSAGE_MAP(CLeftView, CTreeView)
//{{AFX_MSG_MAP(CLeftView)
ON_WM_SHOWWINDOW()
ON_WM_LBUTTONUP()
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLeftView construction/destruction
CLeftView::CLeftView()
{
// TODO: add construction code here
// 初始化树视图所要用到的图像列表
imgList.Create(16,16,true,2,2);
//load bitmaps
CBitmap bitmap;
// 0
bitmap.LoadBitmap(IDB_CLOSE);
imgList.Add(&bitmap,(COLORREF)0XFFFFFF);
bitmap.DeleteObject();
// 1
bitmap.LoadBitmap(IDB_OPEN);
imgList.Add(&bitmap,(COLORREF)0XFFFFFF);
bitmap.DeleteObject();
// 2
bitmap.LoadBitmap(IDB_REVOKE);
imgList.Add(&bitmap,(COLORREF)0XFFFFFF);
bitmap.DeleteObject();
// 3
bitmap.LoadBitmap(IDB_VALID_FOLDER);
imgList.Add(&bitmap,(COLORREF)0XFFFFFF);
bitmap.DeleteObject();
// 4
bitmap.LoadBitmap(IDB_INVALID_FOLDER);
imgList.Add(&bitmap,(COLORREF)0XFFFFFF);
bitmap.DeleteObject();
//
bShow = TRUE;
}
CLeftView::~CLeftView()
{
}
BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CTreeView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CLeftView drawing
void CLeftView::OnDraw(CDC* pDC)
{
CCisoCADoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
void CLeftView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
// TODO: You may populate your TreeView with items by directly accessing
// its tree control through a call to GetTreeCtrl().
}
/////////////////////////////////////////////////////////////////////////////
// CLeftView diagnostics
#ifdef _DEBUG
void CLeftView::AssertValid() const
{
CTreeView::AssertValid();
}
void CLeftView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
CCisoCADoc* CLeftView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCisoCADoc)));
return (CCisoCADoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLeftView message handlers
void CLeftView::OnShowWindow(BOOL bShow, UINT nStatus)
{
CTreeView::OnShowWindow(bShow, nStatus);
// 将图像列表与树关联
CTreeCtrl *ptree = &GetTreeCtrl();
ptree->SetImageList(&imgList,TVSIL_NORMAL);
// ptree->SetBkColor(RGB(254,252,237));
}
void CLeftView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// 视图更新时进行绘制
if(!bShow) return;
// 取文档对象
CCisoCADoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// 从文档中取公司的名称
char buf[256] = {0};
pDoc->m_pConF->GetValue("CompanyName",buf);
if(strlen(buf) == 0 ) strcpy(buf,"CA未初始化");
//
CTreeCtrl *ptree = &GetTreeCtrl();
ptree->DeleteAllItems();
//ptree->SetBkColor(RGB(243,224,252));
ptree->ModifyStyle (0,
TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT);
//|TVS_SINGLEEXPAND
TV_INSERTSTRUCT tvstruct;
//initial general tree
tvstruct.hParent=NULL;
tvstruct.item.mask=TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_TEXT;
tvstruct.item.hItem=0;
tvstruct.item.state=0;
tvstruct.item.stateMask=0;
tvstruct.item.cchTextMax=6;
tvstruct.item.cChildren=0;
tvstruct.item.lParam=0;
//root
tvstruct.item.iImage=0;
tvstruct.item.iSelectedImage=1;
tvstruct.item.pszText=buf;
HTREEITEM hDad=ptree->InsertItem(&tvstruct);
//
tvstruct.hParent=hDad;
tvstruct.item.iImage=3;
tvstruct.item.iSelectedImage=3;
tvstruct.item.pszText="有效证书";
HTREEITEM hMon=ptree->InsertItem(&tvstruct);
tvstruct.item.iImage=4;
tvstruct.item.iSelectedImage=4;
tvstruct.item.pszText="吊销证书";
hMon=ptree->InsertItem(&tvstruct);
ptree->Expand(ptree->GetRootItem(),TVE_EXPAND);
bShow = FALSE;
}
void CLeftView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTreeView::OnLButtonUp(nFlags, point);
}
void CLeftView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
CCisoCADoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CTreeCtrl *ptree = &GetTreeCtrl();
HTREEITEM hitem;
hitem=ptree->GetSelectedItem();
CString strText=ptree->GetItemText(hitem);
CMainFrame *pFrm =(CMainFrame*)((CCisoCAApp*)AfxGetApp())->m_pMainWnd;
CListCtrl *pList = (CListCtrl*)pFrm->GetRightPane();
if(strText=="有效证书")
pDoc->SelectDB(WANT_TO_SHOW_VALID_CERT,pList);
if(strText=="吊销证书")
pDoc->SelectDB(WANT_TO_SHOW_REVOKE_CERT,pList);
pDoc->UpdateAllViews((CView*)pFrm->GetRightPane());
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -