?? examstudentview.cpp
字號:
// ExamStudentView.cpp : 實現文件
//
#include "stdafx.h"
#include "StudentScore.h"
#include "ExamStudentView.h"
#include "ExamStudentDoc.h"
#include "AddStudentDialog.h"
// CExamStudentView
IMPLEMENT_DYNCREATE(CExamStudentView, CFormView)
CExamStudentView::CExamStudentView()
: CFormView(CExamStudentView::IDD)
{
}
CExamStudentView::~CExamStudentView()
{
}
void CExamStudentView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CExamStudentView, CFormView)
ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnNMRclickList1)
ON_COMMAND(ID_159, onAddStudent)
ON_COMMAND(ID_190, OnDelStudent)
END_MESSAGE_MAP()
// CExamStudentView 診斷
#ifdef _DEBUG
void CExamStudentView::AssertValid() const
{
CFormView::AssertValid();
}
void CExamStudentView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
// CExamStudentView 消息處理程序
CExamStudentDoc* CExamStudentView::GetDocument() const
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExamStudentDoc)));
return (CExamStudentDoc*)m_pDocument;
}
void CExamStudentView::OnDraw(CDC* pDC)
{
// TODO: 在此添加專用代碼和/或調用基類
CRect rect;
this->GetClientRect(&rect);
CListCtrl* pList=(CListCtrl*) this->GetDlgItem(IDC_LIST1);
pList->MoveWindow(&rect);
}
void CExamStudentView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CListCtrl* pList=(CListCtrl*) this->GetDlgItem(IDC_LIST1);
pList->SetExtendedStyle( LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES );
// TODO: 在此添加專用代碼和/或調用基類
CExamStudentDoc* pDoc=this->GetDocument();
pDoc->m_ExamStudent.FillList(*pList);
this->m_CurRecordPos=-1;
}
void CExamStudentView::OnNMRclickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知處理程序代碼
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
this->m_CurRecordPos=pNMLV->iItem;
CMenu menu1;
CPoint p;
menu1.LoadMenu(IDR_MENU3);
CMenu* menu2=menu1.GetSubMenu(0);
GetCursorPos(&p);
menu2->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON ,p.x,p.y,this);
*pResult = 0;
}
void CExamStudentView::onAddStudent()
{
// TODO: 在此添加命令處理程序代碼
CExamStudentDoc* pDoc=this->GetDocument();
CAddStudentDialog dlg;
dlg.m_ExamNo=pDoc->m_ExamNo;
dlg.m_ClassNo=pDoc->m_ExamClassNo;
dlg.pExamStudentView=this;
dlg.DoModal();
}
void CExamStudentView::RefreshShow()
{
CExamStudentDoc* pDoc=this->GetDocument();
CListCtrl* pList=(CListCtrl*) this->GetDlgItem(IDC_LIST1);
pDoc->m_ExamStudent.GetExamStudentBy(pDoc->m_ExamNo,pDoc->m_ExamClassNo);
pDoc->m_ExamStudent.FillList(*pList);
}
void CExamStudentView::OnDelStudent()
{
// TODO: 在此添加命令處理程序代碼
CString value;
CExamStudentDoc* pDoc=this->GetDocument();
CListCtrl* list=(CListCtrl*)this->GetDlgItem(IDC_LIST1);
value=list->GetItemText(this->m_CurRecordPos,0);
if(MessageBox("真的要刪除編號為:"+value+"的記錄嗎?","刪除詢問",
MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
{
pDoc->m_ExamStudent.DelStudentByNo(value);
this->RefreshShow();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -