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

📄 pmzdlg.cpp

📁 是我大学事情开发的一个很经典的案例
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// pmzDlg.cpp : implementation file
//

#include "stdafx.h"
#include "pmz.h"
#include "pmzDlg.h"

#include "loginDlg.h"
#include "addyuanxixinxiDlg.h"
#include "chaxunyuanxixinxiDlg.h"
#include "chaxunkechengxinxiDlg.h"
#include "addnew_adminDlg.h"
#include "addjiaoshixinxiDlg.h"
#include "chaxunjiaoshixinxiDlg.h"
#include "addxueshengxinxiDlg.h"
#include "flquerystu_infoDlg.h"
#include "zhquerystu_infoDlg.h"
#include "queryadmin_infoDlg.h"
#include "addkechengxinxiDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPmzDlg dialog

CPmzDlg::CPmzDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPmzDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPmzDlg)
	m_strTime = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_ShowTitle = TRUE;
	m_ReSizeFlag = FALSE;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CPmzDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPmzDlg)
	DDX_Text(pDX, IDC_TIME, m_strTime);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPmzDlg, CDialog)
	//{{AFX_MSG_MAP(CPmzDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_COMMAND(ID_MENUITEM32772, Onupdatemima)
	ON_COMMAND(ID_MENUITEM32771, Onaddnewadmin)
	ON_COMMAND(ID_MENUITEM32783, Onexit)
	ON_COMMAND(ID_MENUITEM32774, Onaddyuanxixinxi)
	ON_COMMAND(ID_MENUITEM32775, Onchaxunyuanxixinxi)
	ON_COMMAND(ID_MENUITEM32776, Onaddjiaoshixinxi)
	ON_COMMAND(ID_MENUITEM32777, Onchaxunjiaoshixinxi)
	ON_COMMAND(ID_MENUITEM32778, Onaddxueshengxinxi)
	ON_COMMAND(ID_fenleichaxun, Onfenleichaxun)
	ON_COMMAND(ID_zuhechaxun, Onzuhechaxun)
	ON_COMMAND(ID_MENUITEM32773, Onqueryadmin_info)
	ON_COMMAND(ID_MENUITEM32780, Onaddkechengxinxi)
	ON_COMMAND(ID_MENUITEM32781, Onchaxunkechengxinxi)
	ON_WM_TIMER()
	ON_WM_CLOSE()
	ON_WM_MOUSEMOVE()
	ON_WM_SIZE()

	ON_WM_QUERYDRAGICON()
	ON_WM_NCLBUTTONDOWN()
	ON_WM_NCMOUSEMOVE()
	ON_WM_SYSCOMMAND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPmzDlg message handlers

BOOL CPmzDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_ToolTip.Create(this,TTS_ALWAYSTIP);//创建工具提示控件,TTS_ALWAYSTIP表示,	
	m_ReSizeFlag  = TRUE;
	CRect rtWnd;
	GetClientRect(rtWnd);
	m_OldWidth = rtWnd.Width();
	m_OldHeight = rtWnd.Height();
	// TODO: Add extra initialization here
	SetTimer(0,100,NULL);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CPmzDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if (nID == SC_CLOSE)
	{
		AfxGetMainWnd()->DestroyWindow();//关闭应用程序
		return;
	}
	if (nID == SC_RESTORE)
	{
		ShowWindow(SW_NORMAL);//restore应用程序
		m_ShowTitle = TRUE;
		return;
	}

	CDialog::OnSysCommand(nID, lParam);
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CPmzDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting
   
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPmzDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CPmzDlg::Onupdatemima()   //打开修改密码对话框  
{
 updatemima.admin_ID=admin_ID;
 updatemima.admin_old_mima=admin_old_mima;
 updatemima.DoModal();
	
}

void CPmzDlg::Onaddnewadmin()   //打开添加管理员信息对话框
{
	if(admin_right.GetAt(0)!='0')
	{
		AfxMessageBox("你没有此权限!");
	}
	else
	{
	   addnew_adminDlg addadmin;
	   addadmin.DoModal();	
	}	
	
}

void CPmzDlg::Onexit()           //退出的功能
{
  CDialog::OnCancel();	
}

void CPmzDlg::Onaddyuanxixinxi()   //打开添加院系信息的对话框
{
	//addyuanxixinxiDlg addyuanxixinxi;
	//addyuanxixinxi.DoModal();
	addyuanxixinxiDlg *addyuanxixinxi;
	addyuanxixinxi = new addyuanxixinxiDlg;
	addyuanxixinxi->Create(IDD_addyuanxixinxi_DIALOG);
	addyuanxixinxi->ShowWindow(SW_SHOW);
}

void CPmzDlg::Onchaxunyuanxixinxi()  //打开查询院系信息的对话框
{
    chaxunyuanxixinxiDlg chaxunyuanxixinxi;
    chaxunyuanxixinxi.DoModal();
}

void CPmzDlg::Onaddjiaoshixinxi() //打开添加教师信息的对话框
{
  addjiaoshixinxiDlg  addjiaoshixinxi;
  addjiaoshixinxi.DoModal();
}

void CPmzDlg::Onchaxunjiaoshixinxi()   //打开查询教师信息的对话框
{
	chaxunjiaoshixinxiDlg chaxunjiaoshixinxi;
	chaxunjiaoshixinxi.DoModal();
	
}

void CPmzDlg::Onaddxueshengxinxi()    //打开添加学生信息的对话框
{
	addxueshengxinxiDlg addxueshengxinxi;
	addxueshengxinxi.DoModal();
}

void CPmzDlg::Onfenleichaxun()  // 分类查询
{
	//flquerystu_infoDlg flqs;
	//flqs.DoModal();
	flquerystu_infoDlg *flqs;
	flqs = new flquerystu_infoDlg;
	flqs->Create(IDD_flquerystuinfo_DIALOG);
	flqs->ShowWindow(SW_SHOW);
}

void CPmzDlg::Onzuhechaxun() //
{
 	zhquerystu_infoDlg zhqs;
	zhqs.DoModal();
}

void CPmzDlg::Onqueryadmin_info() 
{
	if(admin_right.GetAt(0)!='0')
	{
		AfxMessageBox("你没有此权限!");
	}
	else
	{
	   queryadmin_infoDlg queryadmin;
	   queryadmin.DoModal();	
	}
  
}

void CPmzDlg::Onaddkechengxinxi()    //打开添加课程信息对话框
{
	addkechengxinxiDlg addkechengxinxi;
   addkechengxinxi.DoModal();
}

void CPmzDlg::Onchaxunkechengxinxi() //打开查询课程信息对话框
{
	chaxunkechengxinxiDlg chaxunkechengxinxi;
	chaxunkechengxinxi.DoModal();	
}

void CPmzDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CTime m_ctime=CTime::GetCurrentTime();
	int y=m_ctime.GetYear();
	int m=m_ctime.GetMonth();
	int d=m_ctime.GetDay();
	int w=m_ctime.GetDayOfWeek();
	int H=m_ctime.GetHour();
	int M=m_ctime.GetMinute();
	int S=m_ctime.GetSecond();
	m_strTime= m_ctime.FormatGmt("今天是%y年%m月%d日--星期%w--%H:%M:%S");//当前日期
	//m_strTime= m_ctime.Format("%Y年%M月%D日 %H:%M:%S");//当前日期
    CStatic* m_strStatic=(CStatic*)GetDlgItem(IDC_TIME);
	m_strStatic->SetWindowText("今天是:"+m_strTime);

	CDialog::OnTimer(nIDEvent);
}

void CPmzDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	KillTimer(0);
	CDialog::OnClose();
}



LRESULT CPmzDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	LRESULT lrst=CDialog::DefWindowProc(message, wParam, lParam);
	
	if (!::IsWindow(m_hWnd))
		return lrst;
	
	if (message==WM_MOVE||message==WM_PAINT||message==WM_NCPAINT||message==WM_NCACTIVATE ||message == WM_NOTIFY)
	{
		CDC* pWinDC = GetWindowDC();
		if (pWinDC)
			DrawTitleBar(pWinDC);
		ReleaseDC(pWinDC);
	}
	return lrst;
}

⌨️ 快捷键说明

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