⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chakanstudlg.cpp

📁 是我大学事情开发的一个很经典的案例
💻 CPP
字号:
// chakanstuDlg.cpp : implementation file
//

#include "stdafx.h"
#include "pmz.h"
#include "chakanstuDlg.h"
#include "pmzDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// chakanstuDlg dialog
extern CString user_name;

chakanstuDlg::chakanstuDlg(CWnd* pParent /*=NULL*/)
	: CDialog(chakanstuDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(chakanstuDlg)
	m_grade = _T("");
	//}}AFX_DATA_INIT
	m_pdb=new CDatabase;                        //yang
	m_pdb->Open( NULL, FALSE, FALSE,mydb);      //yang
}


chakanstuDlg::~chakanstuDlg()
{
	m_pdb->Close();                               //yang
	delete m_pdb;                                 //yang
}

void chakanstuDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(chakanstuDlg)
	DDX_Control(pDX, IDC_LIST1, m_pList);
	DDX_Text(pDX, IDC_EDIT1, m_grade);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(chakanstuDlg, CDialog)
	//{{AFX_MSG_MAP(chakanstuDlg)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// chakanstuDlg message handlers
 
BOOL chakanstuDlg::OnInitDialog()
{   CDialog::OnInitDialog();
	CListCtrl* m_pList = (CListCtrl*)GetDlgItem(IDC_LIST1);
 	DWORD dwStyle= GetWindowLong(m_pList->m_hWnd, GWL_STYLE); 
    SetWindowLong( m_pList->m_hWnd, GWL_STYLE, dwStyle | LVS_REPORT);
 	
 	//设置ListCtrl可以整行选择和网格条纹
 	DWORD styles = m_pList->GetExtendedStyle();
 	m_pList->SetExtendedStyle(styles|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
 	m_pList->SetBkColor(RGB(0xFF, 0xFF, 0xE0));
  	m_pList->SetTextBkColor(RGB(0xFF, 0xFF, 0xE0));


    //设置列的题头
	m_pList->InsertColumn(1,"学号",LVCFMT_CENTER,80);
	m_pList->InsertColumn(2,"姓名",LVCFMT_CENTER,120);
	m_pList->InsertColumn(3,"性别",LVCFMT_CENTER,80);
	m_pList->InsertColumn(4,"班级",LVCFMT_CENTER,120);
	m_pList->InsertColumn(5,"课程名",LVCFMT_CENTER,180);
	m_pList->InsertColumn(6,"分数",LVCFMT_CENTER,80);
    


	/*CString str1="select * from C_info where T_no='"+user_name+"' ";
	m_pList->DeleteAllItems();
	m_cprecordset=new kecheng_infodb(m_pdb);
	m_cprecordset->Open(kecheng_infodb::snapshot,str1);
	int i=0;
	if(m_cprecordset->IsEOF())
	{
      return true;
	}
	else
	{
	  m_cprecordset->MoveFirst();
	  while(!m_cprecordset->IsEOF())
	  {
       CString strcno=m_cprecordset->m_C_no;
	   CString str2="select * from SC_info where C_no='"+strcno+"' ";
	   m_scprecordset=new SC_infodb(m_pdb);
	   m_scprecordset->Open(SC_infodb::snapshot,str2);
	     while(!m_scprecordset->IsEOF())
		 {
		  CString strsno=m_scprecordset->m_S_no;
		  CString str3="select * from S_info where S_no='"+strsno+"' ";
	      m_sprecordset=new S_infodb(m_pdb);
	      m_sprecordset->Open(S_infodb::snapshot,str3);
		     if(m_sprecordset->IsEOF())
			 {
                 return true;
			 }
			 else 
			 {
				 CStrint sno,sname,ssex,sclass,cname,grade;
				 sno=m_scprecordset->m_S_no;
				 sname=m_sprecordset->m_S_name;
				 ssex=m_sprecordset->m_S_sex;
				 sclass=m_sprecordset->m_S_class;
				 cname=m_cprecordset->m_C_name;
				 grade=m_scprecordset->m_grade;



				 m_pList->InsertItem(i,sno);
		         m_pList->SetItemText(i,1,sname);
	             m_pList->SetItemText(i,2,ssex);
		         m_pList->SetItemText(i,3,sclass);
		         m_pList->SetItemText(i,4,cname);
		         m_pList->SetItemText(i,5,grade);
		         
			 }
		    m_sprecordset->MoveNext();
		 }

        m_cprecordset->MoveNext();
      }
	}
	*/
    return true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -