📄 横店集团保卫人员管理系统dlg.cpp
字号:
// 横店集团保卫人员管理系统Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "横店集团保卫人员管理系统.h"
#include "横店集团保卫人员管理系统Dlg.h"
#include "renyuan.h"
#include "retiredw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString InitName;
extern CString InitPas;
/////////////////////////////////////////////////////////////////////////////
// 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)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_name = _T("");
m_pas = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDC_PICTURE, m_picture);
DDX_Text(pDX, IDC_EDIT1, m_name);
DDX_Text(pDX, IDC_EDIT2, m_pas);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnSure)
ON_BN_CLICKED(IDC_BUTTON2, OnQuit)
ON_WM_CTLCOLOR()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::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
this->SetWindowText("横店集团保卫处管理信息系统");
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind('\\');
sPath=sPath.Left (nPos);
sPath+="\\picture\\start.bmp";
HBITMAP hbitmap;
hbitmap=(HBITMAP)::LoadImage(NULL,sPath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
m_picture.SetBitmap(hbitmap);
startx=starty=0;
CRect rect;
GetWindowRect(rect);
partx=rect.right/60;
party=rect.bottom/60;
SetTimer(1,1,NULL);
m_enter=false;
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
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 CMyDlg::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
{
CRect rect;
CPaintDC dc(this);
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(245,200,173));
CFont font;
font.CreateFont(20,15,0,0,0,0,0,0,0,0,0,0,0,"宋体");
dc.SelectObject(&font);
dc.SetTextColor(RGB(9,201,68));
dc.TextOut(50,100,"横店集团保卫处管理信息系统");
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent==1)
{
CRect rect;
GetWindowRect(rect);
if(startx<rect.right/2)
{
CDC *pDC=GetDC();
BeginPath(pDC->m_hDC);
SetBkMode(pDC->m_hDC,TRANSPARENT);
pDC->MoveTo(rect.right/2-startx,rect.bottom/2-starty);
pDC->LineTo(rect.right/2-startx,rect.bottom/2+starty);
pDC->LineTo(rect.right/2+startx,rect.bottom/2+starty);
pDC->LineTo(rect.right/2+startx,rect.bottom/2-starty);
pDC->LineTo(rect.right/2-startx,rect.bottom/2-starty);
EndPath(pDC->m_hDC);
hrgn=PathToRegion(pDC->m_hDC);
SetWindowRgn(hrgn,true);
SetWindowPos(NULL,startx-100,starty-100,0,0,SWP_NOSIZE);
startx+=partx;
starty+=party;
}
else
{
KillTimer(1);
}
}
else if(nIDEvent==2)
{
CRect rect;
GetWindowRect(rect);
if(startx>0)
{
CDC *pDC=GetDC();
BeginPath(pDC->m_hDC);
SetBkMode(pDC->m_hDC,TRANSPARENT);
pDC->MoveTo(rect.right/2-startx,rect.bottom/2-starty);
pDC->LineTo(rect.right/2-startx,rect.bottom/2+starty);
pDC->LineTo(rect.right/2+startx,rect.bottom/2+starty);
pDC->LineTo(rect.right/2+startx,rect.bottom/2-starty);
pDC->LineTo(rect.right/2-startx,rect.bottom/2-starty);
EndPath(pDC->m_hDC);
hrgn=PathToRegion(pDC->m_hDC);
SetWindowRgn(hrgn,true);
SetWindowPos(NULL,startx,starty,0,0,SWP_NOSIZE);
startx-=partx;
starty-=party;
}
else
{
KillTimer(2);
KillTimer(1);
this->OnOK();
if(m_enter)
{
CRenYuan ren;
ren.DoModal();
}
}
}
CDialog::OnTimer(nIDEvent);
}
void CMyDlg::OnSure()
{
UpdateData(true);
InitName=m_name;
InitPas=m_pas;
if(m_name.IsEmpty()||m_pas.IsEmpty())
MessageBox("请输入完整!");
else
{
CRetiredW work;
work.m_strFilter="用户名='"+m_name+"' and 密码='"+m_pas+"'";
work.Open();
if(work.IsEOF())
MessageBox("没有此账号或密码错误!");
else //记录账户级别
{
m_enter=true;
SetTimer(2,1,NULL);
}
work.Close();
}
// TODO: Add your control notification handler code here
}
HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID()==IDC_BUTTON1||pWnd->GetDlgCtrlID()==IDC_BUTTON2)
{
pDC->SetTextColor(RGB(255,0,0));
}
if(nCtlColor == CTLCOLOR_STATIC )
{
static HBRUSH hbrEdit = ::CreateSolidBrush( RGB(245,200,173) );
pDC->SetBkMode ( TRANSPARENT );
pDC->SetBkColor(RGB(245,200,173));
return hbrEdit;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN)
this->OnSure();
}
return CDialog::PreTranslateMessage(pMsg);
}
void CMyDlg::OnQuit()
{
SetTimer(2,1,NULL);
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -