MFC Learning Section 8: The data in the database is displayed in the window (when multiple students are displayed)


 Continue to section 7 1. Add header file #include<afxdb.h>
 in student.h ; 2. Add header file #include "student.h" in view.cpp;
 3. Create OnRButtonDown function;
 4. Change The fixed display coordinates in the OnLButtonDown function can be used;
void CDdView::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
					

         CStudent rs;
	int y=20;
         CClientDC dc(this);
	rs.Open();
         CString strTemp;

	while(!rs.IsEOF())
	{
	 
	
		strTemp.Format("id:%s,name:%s,english:%d",rs.m_ID,rs.m_name,rs.m_english);
	         rs.MoveNext();
		dc.TextOut(20,y,strTemp);
		y+=20;
	}
       
	
	CView::OnRButtonDown(nFlags, point);
}

Guess you like

Origin blog.csdn.net/u010256329/article/details/9417457