📄 leftview.cpp
字号:
// LeftView.cpp : CLeftView 类的实现
//
#include "stdafx.h"
#include "HW_sigal.h"
#include "HW_sigalDoc.h"
#include "LeftView.h"
#include "HwReadWrite.h"
#include ".\leftview.h"
#include ".\IoSingleDlg.h"
#include ".\HW_sigalView.h"
#include ".\PCIConfigDlg.h"
#include ".\CmosAccessDlg.h"
#include ".\PhyMemDumpDlg.h"
#include ".\SMBiosInfoDlg.h"
#include ".\SMBiosInformation.h"
#include ".\PortSeqRwDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//define the string in the tree node, this is for the display dialog in the right
#define Text_IO_Singal _T("Signal IO port R/W")
#define Text_IO_Group _T("Group IO ports Read")
#define Text_PCI_Index _T("PCI Device Read/Write")
#define Text_CMOS_Reg _T("CMOS Register Read/Write")
#define Text_PHYMEM_Dump _T("Physical Memory Access")
#define Text_SMBIOS_Info _T("SMBios Information")
#define Text_IO_Seq _T("Sequence IO port R/W")
// CLeftView
IMPLEMENT_DYNCREATE(CLeftView, CTreeView)
BEGIN_MESSAGE_MAP(CLeftView, CTreeView)
ON_NOTIFY_REFLECT(NM_CLICK, OnNMClick)
ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclk)
END_MESSAGE_MAP()
// CLeftView 构造/析构
CLeftView::CLeftView()
{
// TODO: 在此处添加构造代码
gpHwRw = NULL;
}
CLeftView::~CLeftView()
{
if(gpHwRw)
{
delete gpHwRw;
}
}
BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或样式
return CTreeView::PreCreateWindow(cs);
}
void CLeftView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
// TODO: 调用 GetTreeCtrl() 直接访问 TreeView 的树控件,
// 从而可以用项填充 TreeView。
gpHwRw = new CHwReadWrite();
pCtrl = &GetTreeCtrl();
ASSERT(pCtrl != NULL);
// Insert a root item using the structure. We must
// initialize a TVINSERTSTRUCT structure and pass its
// address to the call.
TCHAR computerName[MAX_COMPUTERNAME_LENGTH+1];
DWORD bufCharCount = MAX_COMPUTERNAME_LENGTH+1;
GetComputerName(computerName, &bufCharCount);
TVINSERTSTRUCT tvInsert;
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = NULL;
tvInsert.item.mask = TVIF_IMAGE|TVIF_TEXT|TVIF_PARAM|TVIF_HANDLE;
tvInsert.item.pszText = _T(computerName);
LONG lStyle;
lStyle = GetWindowLong(this->m_hWnd, GWL_STYLE);
lStyle |= TVS_LINESATROOT;
lStyle |= TVS_HASBUTTONS;
lStyle |= TVS_HASLINES; // Add the TVS_HASLINES style again.
SetWindowLong(this->m_hWnd, GWL_STYLE, lStyle);
HTREEITEM hDevicesRoot = pCtrl->InsertItem(&tvInsert);
HTREEITEM hPciRoot = pCtrl->InsertItem(Text_PCI_Index, hDevicesRoot, NULL);
HTREEITEM hCmosRoot = pCtrl->InsertItem(Text_CMOS_Reg, hDevicesRoot, NULL);
HTREEITEM hIoPortsRoot = pCtrl->InsertItem(_T("IO ports Read/Write"),
0, 0, hDevicesRoot, hDevicesRoot);
HTREEITEM hMemDumpRoot = pCtrl->InsertItem(Text_PHYMEM_Dump,
0, 0, hDevicesRoot, hDevicesRoot);
HTREEITEM hSMBiosRoot = pCtrl->InsertItem(Text_SMBIOS_Info,
0, 0, hDevicesRoot, hDevicesRoot);
//add sm bios
addSMBiosInfo(pCtrl, hSMBiosRoot);
pCtrl->Expand(hDevicesRoot,TVE_EXPAND);
pCtrl->InsertItem(Text_IO_Singal, hIoPortsRoot, 0);
pCtrl->InsertItem(Text_IO_Seq, hIoPortsRoot, 0);
pCtrl->InsertItem(Text_IO_Group, hIoPortsRoot, 0);
}
// CLeftView 诊断
#ifdef _DEBUG
void CLeftView::AssertValid() const
{
CTreeView::AssertValid();
}
void CLeftView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
CHW_sigalDoc* CLeftView::GetDocument() // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHW_sigalDoc)));
return (CHW_sigalDoc*)m_pDocument;
}
#endif //_DEBUG
// CLeftView 消息处理程序
void CLeftView::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知处理程序代码
*pResult = 0;
}
void CLeftView::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知处理程序代码
HTREEITEM hItem = pCtrl->GetSelectedItem();
CString hItemText = pCtrl->GetItemText(hItem);
if(hItemText == CString(Text_IO_Singal))
{
this->GetDocument()->pSigalView->SetFocus();
CIoSingleDlg* pDialog = new CIoSingleDlg;
BOOL ret = pDialog->Create(IDD_DIALOG_IO_SINGLE,this->GetDocument()->pSigalView);
pDialog->ShowWindow(SW_SHOW);
this->GetDocument()->pSigalView->SetFocus();
}else if(hItemText == CString(Text_IO_Seq))
{
CPortSeqRwDlg* pDialog = new CPortSeqRwDlg;
BOOL ret = pDialog->Create(IDD_DIALOG_SEQUENCE_PORT,this->GetDocument()->pSigalView);
pDialog->ShowWindow(SW_SHOW);
}
else if(hItemText == CString(Text_IO_Group))
{
}else if(hItemText == CString(Text_PCI_Index))
{
CPCIConfigDlg* pDialog = new CPCIConfigDlg;
BOOL ret = pDialog->Create(IDD_DIALOG_PCI_ACCESS,this->GetDocument()->pSigalView);
pDialog->ShowWindow(SW_SHOW);
}else if(hItemText == CString(Text_CMOS_Reg))
{
CCmosAccessDlg* pDialog = new CCmosAccessDlg;
BOOL ret = pDialog->Create(IDD_DIALOG_CMOS_REG,this->GetDocument()->pSigalView);
pDialog->ShowWindow(SW_SHOW);
}else if(hItemText == CString(Text_PHYMEM_Dump))
{
CPhyMemDumpDlg* pDialog = new CPhyMemDumpDlg;
BOOL ret = pDialog->Create(IDD_DIALOG_MEMORY_DUMP,this->GetDocument()->pSigalView);
pDialog->ShowWindow(SW_SHOW);
}else if(hItemText == CString(Text_SMBIOS_Info))
{
}
else
{
int index;
index = hItemText.Find("(Type ", 0);
if(index != -1)
{
//what is the type
DWORD typeNum = pCtrl->GetItemData(hItem);
CSMBiosInfoDlg* pDialog = new CSMBiosInfoDlg(this, typeNum);
BOOL ret = pDialog->Create(IDD_DIALOG_BIOS_INFO,this->GetDocument()->pSigalView);
pDialog->ShowWindow(SW_SHOW);
}
}
*pResult = 0;
}
int CLeftView::addSMBiosInfo(CTreeCtrl* pCtrl, HTREEITEM hSMBiosRoot)
{
char typeName[128] = {0};
m_smBiosInfo.getInfoTypeBytes();
list <DMITYPEINFO>::iterator it;
DWORD index = 0;
it = m_smBiosInfo.listDMITypeInfo.begin();
for(; it != m_smBiosInfo.listDMITypeInfo.end(); index++, it++)
{
CString strTemp;
HTREEITEM hItem;
int typeNum = it->dmiHeader.bType;
m_smBiosInfo.GetSMTypeName(typeNum, typeName);
//strTemp.Format("%d", typeNum);
strTemp.Format("%s(Type %d)", typeName, typeNum);
hItem = pCtrl->InsertItem(_T(strTemp), hSMBiosRoot, 0);
pCtrl->SetItemData(hItem, index);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -