📄 zyjtree.cpp
字号:
// zyjTree.cpp : implementation file
//
#include "stdafx.h"
#include "hellor14.h"
#include "zyjTree.h"
#include "zyjDatabase.h"
#include"afxdb.h"
#include <adslib.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include <stdlib.h>
extern int x1;
extern int y2;
extern int y3;
/////////////////////////////////////////////////////////////////////////////
// zyjTree dialog
zyjTree::zyjTree(CWnd* pParent /*=NULL*/)
: CDialog(zyjTree::IDD, pParent)
{
//{{AFX_DATA_INIT(zyjTree)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void zyjTree::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(zyjTree)
DDX_Control(pDX, IDC_TREE1, m_tree);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(zyjTree, CDialog)
//{{AFX_MSG_MAP(zyjTree)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// zyjTree message handlers
void zyjTree::OnOK()
{
// TODO: Add extra validation here
HTREEITEM m_CurrentItem=m_tree.GetSelectedItem();
CString str=m_tree.GetItemText(m_CurrentItem);
ads_printf("\nstr=%s",str);
/////////////////////////////////////////////访问数据库部分
CString strDataName="River";
CDatabase db;
zyjDatabase* pMasterSet = NULL;
CString m_column;
try
{
if (db.Open(strDataName))
{
pMasterSet = new zyjDatabase();
pMasterSet->Open();
pMasterSet->MoveFirst();
while (!pMasterSet->IsEOF())
{
if(pMasterSet->m_column2==str)
{
UCHAR filename[200];
strcpy((char*)filename,(LPCTSTR)pMasterSet->m_column6);
ShellExecute(NULL,"open",(char*)filename,NULL,NULL,SW_SHOWNORMAL);
// ShellExecute(handle, "open", path_to_folder, NULL, NULL, SW_SHOWNORMAL);
}
pMasterSet->MoveNext();
}
pMasterSet->Close();
delete pMasterSet;
db.Close();
}
}
catch(CDBException* pe)
{
AfxMessageBox(pe->m_strError);
if (pMasterSet)
{
if (pMasterSet->IsOpen())
{
pMasterSet->Close();
}
delete pMasterSet;
}
if (db.IsOpen())
{
db.Close();
}
pe->Delete();
}
CDialog::OnOK();
}
BOOL zyjTree::OnInitDialog()
{
CDialog::OnInitDialog();
ads_printf("\nx1=%d\n",x1);
ads_printf("\ny2=%d\n",y2);
ads_printf("\ny3=%d\n",y3);
// TODO: Add extra initialization here
//--------------Tree控件操作变量------------------------
TVINSERTSTRUCT tvInsert;
tvInsert.item.mask = TVIF_TEXT;
//--------添加根目录----------------------------------------
HTREEITEM h=m_tree.InsertItem(&tvInsert);
CString test="结构块";
UCHAR parentnode[250];
UCHAR node[200];
strcpy((char*)node,(LPCSTR)test);
HTREEITEM hb=PopulateTree1(node,h);
int ww=0;
/////////////////////////////////////////////访问数据库部分
CString strDataName="River";
CDatabase db;
zyjDatabase* pMasterSet = NULL;
CString m_column;
try
{
if (db.Open(strDataName))
{
pMasterSet = new zyjDatabase();
pMasterSet->Open();
pMasterSet->MoveFirst();
while (!pMasterSet->IsEOF())
{
if(pMasterSet->m_column5==x1)
{
if(pMasterSet->m_column4==y2)
{
if(pMasterSet->m_column3==y3)
{
ww=1;
strcpy((char*)parentnode,(LPCTSTR)pMasterSet->m_column2);
PopulateTree1(parentnode,hb);
}
}
}
pMasterSet->MoveNext();
}
pMasterSet->Close();
delete pMasterSet;
db.Close();
if(ww==0)
{ CString test1="满足要求的结构块不存在";
UCHAR node1[200];
strcpy((char*)node1,(LPCSTR)test1);
HTREEITEM hb=PopulateTree1(node1,h);
AfxMessageBox("满足要求的结构块不存在");
}
}
}
catch(CDBException* pe)
{
AfxMessageBox(pe->m_strError);
if (pMasterSet)
{
if (pMasterSet->IsOpen())
{
pMasterSet->Close();
}
delete pMasterSet;
}
if (db.IsOpen())
{
db.Close();
}
pe->Delete();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
HTREEITEM zyjTree::PopulateTree1(UCHAR node[200],HTREEITEM h1)
{
TV_INSERTSTRUCT tvstruct;
tvstruct.hParent=h1;
tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
const char * str=(LPCTSTR)node;
tvstruct.item.pszText =(char*)str;
HTREEITEM h2=m_tree. InsertItem(&tvstruct);
return h2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -