📄 leibie.cpp
字号:
// Leibie.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "Leibie.h"
#include "database.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLeibie dialog
CLeibie::CLeibie(CWnd* pParent /*=NULL*/)
: CDialog(CLeibie::IDD, pParent)
{
//{{AFX_DATA_INIT(CLeibie)
// NOTE: the ClassWizard will add member initialization here
m_caiming=_T("");
//}}AFX_DATA_INIT
}
void CLeibie::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLeibie)
DDX_Control(pDX, IDC_TREE1, m_tree);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLeibie, CDialog)
//{{AFX_MSG_MAP(CLeibie)
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLeibie message handlers
BOOL CLeibie::OnInitDialog()
{
CDialog::OnInitDialog();
HTREEITEM hti;
CString strCode,itemtext;
char RecordBuf[257],*ptchar,field[257];
WCHAR wcCode[257];
HANDLE hFile;
hFile = CreateFile(DB_CAIPU, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile==INVALID_HANDLE_VALUE) return TRUE;
while(fGetRecord(hFile,RecordBuf))
{
ptchar=RecordBuf;
ptchar=fGetField(ptchar,field,3);
MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
strCode=wcCode;
hti=m_tree.GetRootItem();
while (hti!=NULL)
{
itemtext=m_tree.GetItemText(hti);
if (!strCode.Compare(itemtext))
{
ptchar=RecordBuf;
ptchar=fGetField(ptchar,field,1);
MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
strCode=wcCode;
m_tree.InsertItem(strCode,hti);
break;
}
hti=m_tree.GetNextSiblingItem(hti);
}
if (hti==NULL)
{
hti=m_tree.InsertItem(strCode);
ptchar=RecordBuf;
ptchar=fGetField(ptchar,field,1);
MultiByteToWideChar(CP_ACP,0,field,-1,wcCode,255);
strCode=wcCode;
m_tree.InsertItem(strCode,hti);
}
}
CloseHandle(hFile);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CLeibie::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
HTREEITEM hti;
hti=m_tree.GetSelectedItem();
if (m_tree.GetParentItem(hti)==NULL)
{
m_tree.Expand(hti,TVE_TOGGLE);
return;
}
m_caiming=m_tree.GetItemText(hti);
*pResult = 0;
EndDialog(IDOK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -