📄 moduleview.cpp
字号:
// ModuleView.cpp : implementation file
//
#include "stdafx.h"
#include "TestPaper.h"
#include "ModuleView.h"
#include "Resource.h"
#include "XinQueryDialog.h"
#include "LrDialog.h"
#include "XgDialog.h"
#include "MainFrm.h"
#include "StatDialog.h"
#include "XinDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CModuleView
#define ID_LIST 200004
IMPLEMENT_DYNCREATE(CModuleView, CView)
CModuleView::CModuleView()
{
}
CModuleView::~CModuleView()
{
}
BEGIN_MESSAGE_MAP(CModuleView, CView)
//{{AFX_MSG_MAP(CModuleView)
ON_WM_TIMER()
ON_WM_SETCURSOR()
ON_WM_CREATE()
ON_WM_DESTROY()
ON_COMMAND(ID_BH, OnBh)
ON_COMMAND(ID_LR, OnLr)
ON_COMMAND(ID_XG, OnXg)
ON_COMMAND(ID_SC, OnSc)
ON_COMMAND(ID_QS, OnQs)
//}}AFX_MSG_MAP
ON_NOTIFY(NM_DBLCLK, ID_LIST, OnDblClkList)
ON_NOTIFY(NM_CLICK, ID_LIST, OnClickList)
ON_NOTIFY(NM_RCLICK, ID_LIST, OnRclickList)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModuleView drawing
void CModuleView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CModuleView diagnostics
#ifdef _DEBUG
void CModuleView::AssertValid() const
{
CView::AssertValid();
}
void CModuleView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CModuleView message handlers
void CModuleView::Show()//自定义显示函数
{
CRect rc;
GetClientRect(&rc);
MyList=new CListCtrl;
MyList->Create(WS_CHILD|WS_VISIBLE|LVS_ICON|WS_BORDER,rc,this,ID_LIST);
m_ImageList = new CImageList;
m_ImageList->Create(
32, // 图标宽度
32, // 图标长度
1,
6, // 初始的图标个数
1); // 每次的增加值
HICON hIcon;
hIcon=AfxGetApp()->LoadIcon(IDI_ICON);
for(int i = 0;i < 6;i ++)
{
m_ImageList->Add(hIcon);
}
MyList->SetImageList(m_ImageList,LVSIL_NORMAL);
MyList->InsertItem( 0, "试题编辑", 0 );
MyList->InsertItem( 1, "试题查询", 1 );
MyList->InsertItem( 2, "试题统计", 2 );
MyList->InsertItem( 3, "试卷设置", 3 );
MyList->InsertItem( 4, "试卷生成", 4 );
MyList->InsertItem( 5, "答案生成", 5 );
MyList->SetBkColor(RGB(170,170,170));
MyList->SetTextBkColor(RGB(255,255,255));
POINT pt;
UINT j, nCount = MyList->GetItemCount();
for(j=0;j<nCount;j++)
{
switch(j)
{
case 0:MyList->GetItemPosition(j, &pt);
pt.y += 20;
MyList->SetItemPosition(j, pt);
break;
case 1:MyList->GetItemPosition(j, &pt);
pt.y += 40;
MyList->SetItemPosition(j, pt);
break;
case 2:MyList->GetItemPosition(j, &pt);
pt.y += 60;
MyList->SetItemPosition(j, pt);
break;
case 3:MyList->GetItemPosition(j, &pt);
pt.y += 80;
MyList->SetItemPosition(j, pt);
break;
case 4:MyList->GetItemPosition(j, &pt);
pt.y+=100;
MyList->SetItemPosition(j, pt);
break;
case 5:MyList->GetItemPosition(j, &pt);
pt.y += 120;
MyList->SetItemPosition(j, pt);
break;
}
}
}
void CModuleView::OnDblClkList(NMHDR* pNMHDR, LRESULT* pResult)//列表双击函数
{
CTestPaperApp* pApp=(CTestPaperApp*) AfxGetApp();
CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
CPoint cMousePoint;// 鼠标位置
GetCursorPos(&cMousePoint);// 屏幕的鼠标位置,并非窗口的
POINT cListOriginPoint;
CRect cListWindowRect;
UINT uFlags;
MyList->GetWindowRect(&cListWindowRect);
cListOriginPoint = cListWindowRect.TopLeft();
CPoint cTestPoint(cMousePoint.x - cListOriginPoint.x,cMousePoint.y - cListOriginPoint.y);
int nItem = MyList->HitTest(cTestPoint,&uFlags);
if(nItem==0)
{
MessageBox("请右键单击所选项!","题库管理",MB_ICONASTERISK);
}
if(nItem==2)
{
if(pApp->enterdlg.struser!="administrator")
{
AfxMessageBox("对不起!你是一般用户身份!");
return;
}
if(pMainFrame->BoolConnent==FALSE)
{
AfxMessageBox("请连接数据源!");
return;
}
else
{
CStatDialog Statdlg;
Statdlg.DoModal();
}
}
if(nItem==4)
{
if(pApp->enterdlg.struser!="administrator")
{
AfxMessageBox("对不起!你是一般用户身份!");
return;
}
if(pMainFrame->BoolConnent==FALSE)
{
AfxMessageBox("请连接数据源!");
return;
}
else
{
pMainFrame->ChooseTestPaper();
pMainFrame->CreateTestPaper();
}
}
if(nItem==5)
{
if(pApp->enterdlg.struser!="administrator")
{
AfxMessageBox("对不起!你是一般用户身份!");
return;
}
if(pMainFrame->BoolConnent==FALSE)
{
AfxMessageBox("请连接数据源!");
return;
}
else
{
pMainFrame->CreateAnswer();
}
}
if(nItem==1)
{
if(pMainFrame->BoolConnent==FALSE)
{
AfxMessageBox("请连接数据源!");
return;
}
else
{
CXinQueryDialog Querydlg;
Querydlg.DoModal();
}
}
if(nItem==3)
{
if(pApp->enterdlg.struser!="administrator")
{
AfxMessageBox("对不起!你是一般用户身份!");
return;
}
if(pMainFrame->BoolConnent==FALSE)
{
AfxMessageBox("请连接数据源!");
return;
}
else
{
pMainFrame->xindlg.DoModal();
}
}
*pResult = 0;
}
void CModuleView::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) //列表单击函数
{
// TODO: Add your control notification handler code here
CPoint cMousePoint;// 鼠标位置
GetCursorPos(&cMousePoint);// 屏幕的鼠标位置,并非窗口的
POINT cListOriginPoint;
CRect cListWindowRect;
UINT uFlags;
MyList->GetWindowRect(&cListWindowRect);
cListOriginPoint = cListWindowRect.TopLeft();
CPoint cTestPoint(cMousePoint.x - cListOriginPoint.x,cMousePoint.y - cListOriginPoint.y);
int nItem = MyList->HitTest(cTestPoint,&uFlags);
MyList->SetHotItem(nItem);
*pResult = 0;
}
void CModuleView::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) //列表右键单击函数
{
// TODO: Add your control notification handler code here
CPoint cMousePoint;// 鼠标位置
GetCursorPos(&cMousePoint);// 屏幕的鼠标位置,并非窗口的
POINT cListOriginPoint;
CRect cListWindowRect;
UINT uFlags;
MyList->GetWindowRect(&cListWindowRect);
cListOriginPoint = cListWindowRect.TopLeft();
CPoint cTestPoint(cMousePoint.x - cListOriginPoint.x,cMousePoint.y - cListOriginPoint.y);
int nItem = MyList->HitTest(cTestPoint,&uFlags);
if(nItem==0)
{
ClientToScreen(&cTestPoint);
CMenu* pMenu=new CMenu;
pMenu->LoadMenu(IDR_MENU1);
CMenu* pFileMenu=pMenu->GetSubMenu(0);
pFileMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,cTestPoint.x,cTestPoint.y,this);
delete pMenu;
}
*pResult = 0;
}
void CModuleView::OnTimer(UINT nIDEvent) //计数器函数
{
// TODO: Add your message handler code here and/or call default
CMainFrame* pMainFrame=(CMainFrame*) AfxGetMainWnd();
CPoint cMousePoint;// 鼠标位置
GetCursorPos(&cMousePoint);// 屏幕的鼠标位置,并非窗口的
POINT cListOriginPoint;
CRect cListWindowRect;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -