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

📄 testpaperview.cpp

📁 这是目前正应用于辽宁省很多县级中学的试题库系统源代码
💻 CPP
字号:
// TestPaperView.cpp : implementation of the CTestPaperView class
//

#include "stdafx.h"
#include "TestPaper.h"
#include "MainFrm.h"
#include "TestPaperDoc.h"
#include "TestPaperView.h"
#include "XgDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTestPaperView

IMPLEMENT_DYNCREATE(CTestPaperView, CView)

BEGIN_MESSAGE_MAP(CTestPaperView, CView)
	//{{AFX_MSG_MAP(CTestPaperView)
	ON_WM_CREATE()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
	ON_NOTIFY(NM_CLICK, ID_LIST2, OnMyClickList)
	ON_NOTIFY(NM_DBLCLK, ID_LIST2, OnMyDblClkList)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestPaperView construction/destruction

CTestPaperView::CTestPaperView()
{
	// TODO: add construction code here

}

CTestPaperView::~CTestPaperView()
{
}

BOOL CTestPaperView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTestPaperView drawing

void CTestPaperView::OnDraw(CDC* pDC)
{
	CTestPaperDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
//------------------------调整视图大小和列表大小
	CRect rect;
	GetClientRect(rect);
	int Listwid=rect.right-rect.left;
    m_ListCtrl.SetColumnWidth(0,Listwid/10);
	m_ListCtrl.SetColumnWidth(1,Listwid/10);
	m_ListCtrl.SetColumnWidth(2,Listwid/10);
	m_ListCtrl.SetColumnWidth(3,Listwid/10);
	m_ListCtrl.SetColumnWidth(4,Listwid/10);
	m_ListCtrl.SetColumnWidth(5,Listwid/10);
	m_ListCtrl.SetColumnWidth(6,Listwid/10);
	m_ListCtrl.SetColumnWidth(7,Listwid/10);
	m_ListCtrl.SetColumnWidth(8,Listwid/10);
	m_ListCtrl.SetColumnWidth(9,Listwid/10);


//--------------------------end
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CTestPaperView printing

BOOL CTestPaperView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CTestPaperView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CTestPaperView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CTestPaperView diagnostics

#ifdef _DEBUG
void CTestPaperView::AssertValid() const
{
	CView::AssertValid();
}

void CTestPaperView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CTestPaperDoc* CTestPaperView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestPaperDoc)));
	return (CTestPaperDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTestPaperView message handlers

void CTestPaperView::OnInitialUpdate() 
{

	CView::OnInitialUpdate();
	// TODO: Add your specialized code here and/or call the base class
	// Get Client Rect
    CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
    CreateListCtrl();
    pMainFrame->Refreshdata();
}

int CTestPaperView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here


	return 0;
}

void CTestPaperView::CreateListCtrl()//创建列表函数
{
    CRect rect;
	GetClientRect(rect);
	m_ListCtrl.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT, rect, this, ID_LIST2);
	m_ListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP);
    int Listwid=rect.right-rect.left;
    m_ListCtrl.InsertColumn(0,_T("题目编号"),LVCFMT_CENTER,Listwid/10);
	m_ListCtrl.InsertColumn(1,_T("考试对象"),LVCFMT_CENTER,Listwid/10);
    m_ListCtrl.InsertColumn(2,_T("难度级别"),LVCFMT_CENTER,Listwid/10);
    m_ListCtrl.InsertColumn(3,_T("题目内容"),LVCFMT_CENTER,Listwid/10);
	m_ListCtrl.InsertColumn(4,_T("选项A"),LVCFMT_CENTER,Listwid/10);
	m_ListCtrl.InsertColumn(5,_T("选项B"),LVCFMT_CENTER,Listwid/10);
	m_ListCtrl.InsertColumn(6,_T("选项C"),LVCFMT_CENTER,Listwid/10);
    m_ListCtrl.InsertColumn(7,_T("选项D"),LVCFMT_CENTER,Listwid/10);
    m_ListCtrl.InsertColumn(8,_T("标准答案"),LVCFMT_CENTER,Listwid/10);
	m_ListCtrl.InsertColumn(9,_T("识别号"),LVCFMT_CENTER,Listwid/10);




}
void CTestPaperView::OnMyClickList(NMHDR* pNMHDR, LRESULT* pResult) //列表单击函数
{
	// TODO: Add your control notification handler code here
	CPoint cMousePoint;// 鼠标位置
	GetCursorPos(&cMousePoint);// 屏幕的鼠标位置,并非窗口的
    POINT  cListOriginPoint;
	CRect  cListWindowRect;
	UINT uFlags;
	m_ListCtrl.GetWindowRect(&cListWindowRect);
	cListOriginPoint = cListWindowRect.TopLeft();
	CPoint cTestPoint(cMousePoint.x - cListOriginPoint.x,cMousePoint.y - cListOriginPoint.y);
    Myitem = m_ListCtrl.HitTest(cTestPoint,&uFlags);
	m_ListCtrl.SetHotItem(Myitem);
	*pResult = 0;
	
}
void CTestPaperView::OnMyDblClkList(NMHDR* pNMHDR, LRESULT* pResult)//列表双击函数
{
	CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
	if(pApp->enterdlg.struser!="administrator")
	{
		return;
	}
	CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
	int i=m_ListCtrl.GetHotItem();
	if(pMainFrame->BoolConnent==FALSE || pMainFrame->m_recordset.GetRecordCount()==0)
	{
		AfxMessageBox("请连接数据源或无记录!");
		return;
	}
	if(!pMainFrame->m_recordset.CanUpdate())
         return;
	if(i==-1)
	{
		AfxMessageBox("请选择列表项!");
		return;
	}
	pMainFrame->ming=2;
	CXgDialog dlg;
	dlg.DoModal();
}

void CTestPaperView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
}

⌨️ 快捷键说明

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