// StdudentSystemView.cpp: CStdudentSystemView 类的实现
//
#include "stdafx.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义,并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "StdudentSystem.h"
#endif
#include "StdudentSystemDoc.h"
#include "StdudentSystemView.h"
#include "courseset.h"
#include "scoreset.h"
#include "specialset.h"
#include "studentset.h"
#include "CourseDlg.h"
#include "ScoreDlg.h"
#include "SeekDlg.h"
#include "StuInfoDlg.h"
#include "ColorEggDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CStdudentSystemView
IMPLEMENT_DYNCREATE(CStdudentSystemView, CListView)
BEGIN_MESSAGE_MAP(CStdudentSystemView, CListView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, &CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CListView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CStdudentSystemView 构造/析构
CStdudentSystemView::CStdudentSystemView() noexcept
{
// TODO: 在此处添加构造代码
}
CStdudentSystemDoc * CStdudentSystemView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStdudentSystemDoc)));
return (CStdudentSystemDoc*)m_pDocument;
}
CStdudentSystemView::~CStdudentSystemView()
{
}
BOOL CStdudentSystemView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
cs.style |= LVS_REPORT;
return CListView::PreCreateWindow(cs);
}
void CStdudentSystemView::OnPrepareDC(CDC * pDC, CPrintInfo * pInfo)
{
ReadListViewData();
pDC->SetMapMode(MM_LOMETRIC); // 单位0.1mm
CListView::OnPrepareDC(pDC, pInfo);
int nSize = m_strContents.GetSize();
if ((pInfo) && (nSize)) {
if (pInfo->m_nCurPage <= pInfo->GetToPage())
pInfo->m_bContinuePrinting = TRUE;
else
pInfo->m_bContinuePrinting = FALSE;
}
}
void CStdudentSystemView::OnDraw(CDC* /*pDC*/)
{
CStdudentSystemDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: 在此处为本机数据添加绘制代码
}
void CStdudentSystemView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
// TODO: 调用 GetListCtrl() 直接访问 ListView 的列表控件,
// 从而可以用项填充 ListView。
}
// CStdudentSystemView 打印
BOOL CStdudentSystemView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
ReadListViewData();
int nSize = m_strContents.GetSize();
if (nSize < 1) pInfo->SetMaxPage(1);
return DoPreparePrinting(pInfo);
}
void CStdudentSystemView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加额外的打印前进行的初始化过程
}
void CStdudentSystemView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加打印后进行的清理过程
}
void CStdudentSystemView::OnUpdate(CView * pSender, LPARAM lHint, CObject * pHint)
{
CStdudentSystemDoc* pDoc = (CStdudentSystemDoc*) GetDocument();
CString strHint, str;
if (pHint)
{
strHint = *((CString *)pHint);
delete (CString *)pHint;
}
if (pDoc->m_nInfoType == 1) { // 学生信息
switch ((int)lHint)
{
case 1:
case 2:
case 3:
str.Format(L"studentno LIKE '%s%%'", strHint.Left(6));
DispStudentInfo(str, L"studentno");
break;
case 11:
str.Format(L"studentno LIKE '%s%%'", strHint.Left(6));
DispStudentInfo(str, L"studentno");
break;
case 12:
str.Format(L"special = '%s'", strHint);
DispStudentInfo(str, L"studentno");
break;
case 13:
str = "";
DispStudentInfo(str, L"studentno");
break;
}
}
else
if (pDoc->m_nInfoType == 2) { // 课程信息
switch ((int)lHint)
{
case 1:
case 2:
case 3:
str.Format(L"courseno = '%s'", strHint);
DispCourseInfo(str, L"");
break;
case 11:
str.Format(L"special = '%s'", strHint);
DispCourseInfo(str, L"courseno");
break;
case 12:
str.Format(L"special = '%s'", strHint);
DispCourseInfo(str, L"courseno");
break;
case 13:
str = "";
DispCourseInfo(str, L"courseno");
break;
}
}
else
if (pDoc->m_nInfoType == 3) { // 学生成绩
switch ((int)lHint)
{
case 1:
case 2:
case 3:
str.Format(L"studentno = '%s'", strHint);
DispScoreAndCourseInfo(str);
break;
case 11:
str.Format(L"studentno LIKE '%s%%'", strHint.Left(6));
DispScoreAndCourseInfo(str);
break;
case 12:
str.Format(L"special = '%s'", strHint);
DispScoreAndCourseInfo2(str);
break;
case 13:
str = "";
DispScoreAndCourseInfo(str);
break;
}
}
DispStatusRecord();
}
void CStdudentSystemView::OnPrint(CDC * pDC, CPrintInfo * pInfo)
{
CFont font;
font.CreateFontIndirect(&m_pageInfo.lfText);
CFont* oldFont = pDC->SelectObject(&font); // 设置正文字体
SetPageInfo(pDC, pInfo, &m_pageInfo, 250, 250, 250, 250, 35); // 设置页边距和行距
PrintHead(pDC, pInfo, m_pageInfo, L"StudentSystem", 200, -1); // 打印页眉
CString str;
str.Format(L"- %d -", pInfo->m_nCurPage);
PrintFoot(pDC, pInfo, m_pageInfo, str, 200, 0); // 打印页脚
if (m_strContents.GetSize() < 1) return; // 没有文档内容则返回
AdjustAllLine(pDC); // 调整每行的文本
int nIndex = pInfo->m_nCurPage - 1;
int nStartLine = m_nLineArray.GetAt(nIndex);
CRect rc = pInfo->m_rectDraw;
int y = rc.top;
int nHeight = m_pageInfo.sizeLine.cy;
int tab = m_pageInfo.sizeChar.cx * 4; // 为一个TAB设置4个字符
while (y >= pInfo->m_rectDraw.bottom)
{
str = m_arrText.GetAt(nStartLine);
rc.top = y;
pDC->TabbedTextOut(rc.left, y, str, 1, &tab, rc.left);
nStartLine++;
if (nStartLine >= m_arrText.GetSize())
{
pInfo->SetMaxPage(pInfo->m_nCurPage);
pInfo->m_pPD->m_pd.nToPage = pInfo->m_nCurPage;
break;
}
y -= nHeight;
}
if (nIndex >= (m_nLineArray.GetSize() - 1))
m_nLineArray.Add(nStartLine); // 保存下一页的起始行号
pDC->SelectObject(oldFont);
CListView::OnPrint(pDC, pInfo);
}
void CStdudentSystemView::DispStatusRecord()
{
CListCtrl& m_ListCtrl = GetListCtrl();
int nItemCount = m_ListCtrl.GetItemCount();
CString str;
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; // 获得主窗口指针
CStatusBar* pStatus = &pFrame->m_wndStatusBar; // 获得主窗口中的状态栏指针
if (pStatus) {
str.Format(L"当前记录数:%d", nItemCount); // 格式化文本
pStatus->SetPaneText(1, str); // 更新第二个窗格的文本
}
}
CString CStdudentSystemView::AppendStringSpace(CString str, int nNum)
{
for (int i = 0; i < nNum; i++)
str.Insert(500, ' ');
return str;
}
void CStdudentSystemView::AdjustAllLine(CDC * pDC)
{
int nLineNums = m_strContents.GetSize(); // 文档总行数
int tab = m_pageInfo.sizeChar.cx * 4; // 为一个TAB设置4个字符
// 将文档的每一行作换行处理,只处理一次,以提高预览速度
// 处理的结果保存在arrText中
CString str;
m_arrText.RemoveAll();
CSize strSize;
for (int i = 0; i < nLineNums; i++)
{
str = m_strContents.GetAt(i);
strSize = pDC->GetTabbedTextExtent(str, 1, &tab);
CString strTemp = str;
while (strSize.cx > m_pageInfo.sizeLine.cx) {
unsigned int pos = 0;
for (pos = 0; pos < strTemp.GetLength(); pos++) {
CSize size = pDC->GetTabbedTextExtent(strTemp, pos + 1, 1, &tab);
if (size.cx >= m_pageInfo.sizeLine.cx) break;
}
// 判断汉字双字符是否被分开
int nCharHZ = 0;
for (unsigned int chIndex = 0; chIndex <= pos; chIndex++)
if (strTemp.GetAt(chIndex) < 0) nCharHZ++;
if (nCharHZ % 2) pos = pos - 1;
m_arrText.Add(strTemp.Left(pos + 1));
strTemp = strTemp.Mid(pos + 1);
strSize = pDC-
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
学生管理系统,连接数据库后可以对学生信息、课程信息、学生成绩进行增加、修改和删除。.zip (32个子文件)
StudentSystem-master
header
stdafx.h 2KB
ColorEggDlg.h 425B
StdudentSystem.h 611B
studentset.h 1KB
resource.h 3KB
scoreset.h 1KB
StdudentSystemDoc.h 1KB
MainFrm.h 933B
SeekDlg.h 651B
StuInfoDlg.h 925B
CourseDlg.h 792B
specialset.h 1002B
test 5B
StudentSystemTreeView.h 1KB
courseset.h 1KB
targetver.h 299B
StdudentSystemView.h 3KB
ScoreDlg.h 756B
cpp
StudentSystemTreeView.cpp 3KB
specialset.cpp 1KB
CourseDlg.cpp 2KB
scoreset.cpp 2KB
SeekDlg.cpp 2KB
MainFrm.cpp 2KB
StdudentSystemDoc.cpp 6KB
StdudentSystem.cpp 5KB
ColorEggDlg.cpp 549B
StuInfoDlg.cpp 3KB
ScoreDlg.cpp 2KB
stdafx.cpp 183B
StdudentSystemView.cpp 28KB
courseset.cpp 2KB
共 32 条
- 1
资源评论
博士僧小星
- 粉丝: 1935
- 资源: 5894
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 9道Linux性能高频题整理(附答案背诵版).md
- Java毕设项目基于Springboot实现的靓车汽车销售网站+代码+论文+答辩ppt
- 源码:SH79F9202-LCD调试程序io-lcd-key-uart(20240604)(by naiva)
- linux常用命令大全.zip
- 222_20240528_024658
- 223_20240604_025637
- github解说及优缺点.zip
- notepad-plus-plus-8.6.7.zip 解压版 免安装
- MATLAB GUI(图形用户界面)仿真案例开发案列优质学习资料资源工具与案列应用场景开发文档教程资料
- 旨在向工程和科学领域的学生介绍MATLAB
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功