📄 opendlg.cpp
字号:
// Opendlg.cpp : implementation file
//
#include "stdafx.h"
#include "Myknowledge.h"
#include "Opendlg.h"
#include "OpenSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COpendlg dialog
COpendlg::COpendlg(CWnd* pParent /*=NULL*/)
: CDialog(COpendlg::IDD, pParent)
{
//{{AFX_DATA_INIT(COpendlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void COpendlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COpendlg)
DDX_Control(pDX, IDC_LIST1, m_open);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COpendlg, CDialog)
//{{AFX_MSG_MAP(COpendlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COpendlg message handlers
BOOL COpendlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_open.InsertColumn(0,"编号");
m_open.InsertColumn(1,"表名");
m_open.SetColumnWidth(0,60);
m_open.SetColumnWidth(1,250);
m_open.SetExtendedStyle(LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES);
m_query.Format("select * from list order by ID ASC");
Refresh();
this->SetWindowText("选择表");
return TRUE;
}
void COpendlg::Refresh()
{
if(!m_database.IsOpen())
{
m_database.Open(_T("我的知识库"));
}
//对列表控件的内容更新,清空原来的内容
m_open.DeleteAllItems();
//创建记录集
COpenSet m_personset(&m_database);
m_personset.Open(AFX_DB_USE_DEFAULT_TYPE,m_query);
CDBVariant varValue;
//char buf[200];
//用来记录当前记录的序号
int i=0;
//如果表中有记录,打开后将游标定在第一位,使记录集中的第一条记录成为当前记录
if(m_personset.GetRecordCount()!=0) m_personset.MoveFirst();
while(!m_personset.IsEOF())
{
CString s;
s.Format("%d",m_personset.m_0);
m_open.InsertItem(i, s, 0);
m_open.SetItemText(i, 1, m_personset.m_1);
m_personset.MoveNext();
i++;
}
}
void COpendlg::OnOK()
{
//CMywinView myview;
int i=0;
//if(dlg.DoModal()==IDOK);
//{
i=m_open.GetSelectionMark();
m_dlgname=m_open.GetItemText(i,1);
if(i==-1)
{MessageBox("请选择一个表名!","提示",MB_OK|MB_ICONINFORMATION);
return;}
//myview.m_strname=m_open.GetItemText(i,1); //m_0=strname;
//dlg.m_query.Format("select * from %s order by data ASC",strname);
//RefreshData();
//}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -