?? examsubjectview.cpp
字號:
// ExamSubjectView.cpp : 實現文件
//
#include "stdafx.h"
#include "StudentScore.h"
#include "ExamSubjectView.h"
#include "ExamSubjectDoc.h"
#include "AddSubjectDialog.h"
// CExamSubjectView
IMPLEMENT_DYNCREATE(CExamSubjectView, CFormView)
CExamSubjectView::CExamSubjectView()
: CFormView(CExamSubjectView::IDD)
{
}
CExamSubjectView::~CExamSubjectView()
{
}
void CExamSubjectView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CExamSubjectView, CFormView)
ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnNMRclickList1)
ON_COMMAND(ID__163, onAddSubject)
ON_COMMAND(ID_159, On159)
END_MESSAGE_MAP()
// CExamSubjectView 診斷
#ifdef _DEBUG
void CExamSubjectView::AssertValid() const
{
CFormView::AssertValid();
}
void CExamSubjectView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
// CExamSubjectView 消息處理程序
CExamSubjectDoc* CExamSubjectView::GetDocument() const
{
ASSERT(this->m_pDocument->IsKindOf(RUNTIME_CLASS(CExamSubjectDoc)));
return(CExamSubjectDoc*) this->m_pDocument;
}
void CExamSubjectView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CListCtrl* pList=(CListCtrl*) this->GetDlgItem(IDC_LIST1);
pList->SetExtendedStyle( LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES );
// TODO: 在此添加專用代碼和/或調用基類
CExamSubjectDoc* pDoc=this->GetDocument();
pDoc->m_ExamSubject.FillList(*pList);
}
void CExamSubjectView::OnDraw(CDC* /*pDC*/)
{
// TODO: 在此添加專用代碼和/或調用基類
CRect rect;
this->GetClientRect(&rect);
CListCtrl* pList=(CListCtrl*) this->GetDlgItem(IDC_LIST1);
pList->MoveWindow(&rect);
}
void CExamSubjectView::OnNMRclickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 在此添加控件通知處理程序代碼
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
this->m_CurRecordPos=pNMLV->iItem;
CMenu menu1;
CPoint p;
menu1.LoadMenu(IDR_MENU4);
CMenu* menu2=menu1.GetSubMenu(0);
GetCursorPos(&p);
menu2->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON ,p.x,p.y,this);
*pResult = 0;
}
void CExamSubjectView::onAddSubject()
{
// TODO: 在此添加命令處理程序代碼
CExamSubjectDoc* pDoc=this->GetDocument();
CAddSubjectDialog dlg;
dlg.m_pExamSubjectView=this;
dlg.DoModal();
}
void CExamSubjectView::RefreshShow()
{
CExamSubjectDoc* pDoc=this->GetDocument();
pDoc->Refresh();
CListCtrl* pList=(CListCtrl*) this->GetDlgItem(IDC_LIST1);
pDoc->m_ExamSubject.FillList(*pList);
}
void CExamSubjectView::On159()
{
// TODO: 在此添加命令處理程序代碼
CString value;
CExamSubjectDoc* 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_ExamSubject.DelSubjectByNo(value);
this->RefreshShow();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -