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

📄 previewdlg.cpp

📁 课程设计的简单Access学生数据库系统
💻 CPP
字号:
// PreviewDlg.cpp : implementation file
//

#include "stdafx.h"
#include "sm.h"
#include "PreviewDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPreviewDlg dialog


//##ModelId=40A481F5031E
CPreviewDlg::CPreviewDlg(ScoreList * plist ,CString * pemark , CWnd* pParent /*=NULL*/)
	: CDialog(CPreviewDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPreviewDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	pList = plist;
	pRemark = pemark;
	pClass = NULL;
	pUnit = NULL;
	pTeacher = NULL;
}


//##ModelId=40A481F5033D
void CPreviewDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPreviewDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPreviewDlg, CDialog)
	//{{AFX_MSG_MAP(CPreviewDlg)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPreviewDlg message handlers

//##ModelId=40A481F5034C
void CPreviewDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect rc;
	GetClientRect(&rc);
	rc.left+=3, rc.top+=3, rc.bottom-=3, rc.right-=3;
	dc.Rectangle(&rc);
	Draw(dc);
	
	// Do not call CDialog::OnPaint() for painting messages
}

//##ModelId=40A481F5031C
void CPreviewDlg::Draw(CDC &dc)
{
	CString sz[2][15];
	int i, j, count;
	count = pList->GetCount();
	for(i=0;i<count;i++)
	{
		sz[0][i]=pList->ScoreData[i].SubjectTitle;
		sz[1][i].Format("%ld", pList->ScoreData[i].Data.ScoreValue);
	}
	dc.SetBkColor(RGB(255,255,255));
	dc.Rectangle(20, 100, 620, 320);
	for(i=1; i<7; i++)
	{
		dc.MoveTo(20, 100+i*24);
		dc.LineTo(620, 100+i*24);
	}
	for(i=0; i<6; i++)
	{
		dc.MoveTo(20+i*100, 100);
		
		dc.LineTo(20+i*100, i==1?320:100+6*24);
	}
	CFont font, *old_font;
	font.CreatePointFont(200, "宋体", &dc);
	old_font = dc.SelectObject(&font);
	dc.SelectObject(GetStockObject(WHITE_BRUSH));
	DrawText(dc, 20, 40, 620,70, CString("成 绩 单"));
	dc.SelectObject(old_font);
	font.DeleteObject();
	font.CreatePointFont(110, "宋体", &dc);
	old_font = dc.SelectObject(&font);
	dc.SelectObject(GetStockObject(WHITE_BRUSH));
	dc.TextOut(30, 80, "班级:");
	if(pClass)
		dc.TextOut(70, 80, *pClass);
	dc.TextOut(160, 80, "学生:");
	if(pList->GetCount())
	{
		dc.TextOut(200, 80, pList->ScoreData[0].StudentName);
		dc.TextOut(500, 80,  CTime::GetCurrentTime().Format("%Y年%m月%d日"));
	}
	for(i=0; i<6; i++)
	{
		DrawText(dc, 20, 100+24*i+3, 20+100, 100+24*(i+1), CString(i%2==1?"成绩":"课程"));
	}
	DrawText(dc, 20,100+24*6+24, 20+100, 100+24*9, CString("备注"));
	if(pRemark)
		dc.DrawText(*pRemark, &CRect(130,100+24*6+8, 610, 100+24*9), DT_LEFT);
	DrawText(dc, 400, 340, 540, 370, CString("班主任:"));
	if(pTeacher)
		DrawText(dc, 500, 340, 500+pTeacher->GetLength()*10, 370, *pTeacher);
	DrawText(dc, 400, 370, 540, 400, CString("学  校:"));
	if(pUnit)
		DrawText(dc, 500, 370, 500+pUnit->GetLength()*10, 400, *pUnit);
	
	dc.SelectObject(old_font);
	font.DeleteObject();
	font.CreatePointFont(90, "宋体", &dc);
	old_font = dc.SelectObject(&font);
	dc.SelectObject(GetStockObject(WHITE_BRUSH));
	for(i=0,j=0;i<2;i++)
	{
		for(j=0;j<15;j++)
			DrawText(dc, 120+j%5*100, 100+(j/5)*2*24+i*24+5, 220+j%5*100, 100+j/5*2*24+(i+1)*24, sz[i][j]);
	}
	dc.SelectObject(old_font);
	font.DeleteObject();

}

//##ModelId=40A481F50300
void CPreviewDlg::DrawText(CDC &dc, int x1, int y1, int x2, int y2, CString &s)
{
	CRect rc(x1,  y1,  x2,  y2);
	dc.DrawText(s, &rc, DT_CENTER);
}

//##ModelId=40A481F502FE
void CPreviewDlg::SetRemark(CString *premark)
{
	pRemark = premark;
}

//##ModelId=40A481F5035B
BOOL CPreviewDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//##ModelId=40A481F502EE
void CPreviewDlg::Set(CString *strClass, CString *teacher, CString *unit)
{
	pClass = strClass, pTeacher = teacher, pUnit = unit;
}

⌨️ 快捷键说明

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