📄 salarymanagementdlg.cpp
字号:
// SalaryManagementDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SalaryManagement.h"
#include "SalaryManagementDlg.h"
#include "DlgProxy.h"
#include "USkin.h"
#include "StaffDlg.h"
#include "PasswordSetDlg.h"
#include "KaoqinDlg.h"
#include "SalaryDlg.h"
#include "SystemSetDlg.h"
#include "BackupRecovery.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()
/////////////////////////////////////////////////////////////////////////////
// CSalaryManagementDlg dialog
IMPLEMENT_DYNAMIC(CSalaryManagementDlg, CDialog);
CSalaryManagementDlg::CSalaryManagementDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSalaryManagementDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSalaryManagementDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pAutoProxy = NULL;
}
CSalaryManagementDlg::~CSalaryManagementDlg()
{
// If there is an automation proxy for this dialog, set
// its back pointer to this dialog to NULL, so it knows
// the dialog has been deleted.
if (m_pAutoProxy != NULL)
m_pAutoProxy->m_pDialog = NULL;
}
void CSalaryManagementDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSalaryManagementDlg)
DDX_Control(pDX, IDC_ROLL, m_roll);
DDX_Control(pDX, IDC_STATIC13, m_static13);
DDX_Control(pDX, IDC_STATIC18, m_static18);
DDX_Control(pDX, IDC_STATIC17, m_static17);
DDX_Control(pDX, IDC_STATIC16, m_static16);
DDX_Control(pDX, IDC_STATIC15, m_static15);
DDX_Control(pDX, IDC_STATIC9, m_static9);
DDX_Control(pDX, IDC_STATIC11, m_static11);
DDX_Control(pDX, IDC_STATIC10, m_static10);
DDX_Control(pDX, IDC_STATIC12, m_static12);
DDX_Control(pDX, IDC_USERNAME, m_username);
DDX_Control(pDX, IDC_STATIC1, m_static1);
DDX_Control(pDX, IDC_STATIC2, m_static2);
DDX_Control(pDX, IDC_STATIC3, m_static3);
DDX_Control(pDX, IDC_STATIC4, m_static4);
DDX_Control(pDX, IDC_STATIC5, m_static5);
DDX_Control(pDX, IDC_STATIC6, m_static6);
DDX_Control(pDX, IDC_STATIC7, m_static7);
DDX_Control(pDX, IDC_STATIC8, m_static8);
DDX_Control(pDX, IDC_STATIC14, m_static14);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSalaryManagementDlg, CDialog)
//{{AFX_MSG_MAP(CSalaryManagementDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_CLOSE, OnExit)
ON_BN_CLICKED(IDC_MIN, OnMin)
ON_WM_CTLCOLOR()
ON_WM_LBUTTONDOWN()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_STATIC1, OnPesonal)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_STATIC2, OnSalary)
ON_BN_CLICKED(IDC_STATIC3, OnAttendance)
ON_BN_CLICKED(IDC_STATIC4, OnPassworChange)
ON_BN_CLICKED(IDC_STATIC15, OnSystemSet)
ON_BN_CLICKED(IDC_STATIC16, OnBackupAndResume)
ON_BN_CLICKED(IDC_STATIC5, OnStatic5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSalaryManagementDlg message handlers
BOOL CSalaryManagementDlg::OnInitDialog()
{
CDialog::OnInitDialog();
USkinRemoveSkin();
// 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
ModifyStyle(WS_MAXIMIZEBOX,WS_SYSMENU);//添加系统菜单
CMenu* pMenu = this->GetSystemMenu(FALSE);
pMenu->EnableMenuItem(SC_MAXIMIZE,MF_BYCOMMAND | MF_GRAYED ); //屏蔽最大化框
//改变窗口标题
CWnd *m_pMainWnd;
m_pMainWnd=AfxGetMainWnd();
m_pMainWnd->SetWindowText(_T("工资管理系统豪华版"));
//显示用户名
extern CSalaryManagementApp theApp;
CString m_user;
GetDlgItemText(IDC_USERNAME,m_user);
m_user+=theApp.m_username;
SetDlgItemText(IDC_USERNAME,m_user);
m_btnClose.AutoLoad(IDC_CLOSE,this);
m_btnMin.AutoLoad(IDC_MIN,this);
m_btnExit.AutoLoad(IDCANCEL,this);
//初始化静态文本
m_static1.Init();
m_static2.Init();
m_static3.Init();
m_static4.Init();
m_static9.Init();
m_static10.Init();
m_static11.Init();
m_static12.Init();
m_static15.Init();
m_static16.Init();
m_roll.Init();
//设置字体为系统字体
CFont *font=GetFont();
LOGFONT logFont;
font->GetLogFont(&logFont);
m_static5.SetFont(logFont);
m_static6.SetFont(logFont);
m_static7.SetFont(logFont);
m_static8.SetFont(logFont);
m_static13.SetFont(logFont);
m_static14.SetFont(logFont);
m_static17.SetFont(logFont);
m_static18.SetFont(logFont);
m_username.SetFont(logFont);
//不响应鼠标移动的消息
m_static5.SetMouseMove(FALSE);
m_static6.SetMouseMove(FALSE);
m_static7.SetMouseMove(FALSE);
m_static8.SetMouseMove(FALSE);
m_static13.SetMouseMove(FALSE);
m_static14.SetMouseMove(FALSE);
m_static17.SetMouseMove(FALSE);
m_static18.SetMouseMove(FALSE);
m_username.SetMouseMove(FALSE);
m_roll.SetMouseMove(FALSE);
//设置鼠标移到和移出控件时,右边显示的提示信息
m_static1.SetToopTip(&m_static13,IDS_STRING1,IDS_STRING0);
m_static2.SetToopTip(&m_static13,IDS_STRING2,IDS_STRING0);
m_static3.SetToopTip(&m_static13,IDS_STRING3,IDS_STRING0);
m_static4.SetToopTip(&m_static13,IDS_STRING4,IDS_STRING0);
m_static15.SetToopTip(&m_static13,IDS_STRING5,IDS_STRING0);
m_static16.SetToopTip(&m_static13,IDS_STRING6,IDS_STRING0);
//设置不透明
m_static13.RemoveTransparent();
m_static13.SetRedraw(FALSE);
m_roll.RemoveTransparent();
m_roll.SetRedraw(FALSE);
SetTimer(1,1000,NULL);
//提示信息初始化
// m_tooltip.Create(this);
// m_tooltip.AddTool(GetDlgItem(IDC_STATIC1),"人事管理",RGB(234,56,78));
return TRUE; // return TRUE unless you set the focus to a control
}
void CSalaryManagementDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CSalaryManagementDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
if (IsIconic())
{
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;
GetClientRect(rect);
CBitmap bitmap;
bitmap.LoadBitmap (IDB_INTERFACE);
CDC CompatibleDC;
CompatibleDC.CreateCompatibleDC(&dc);
CBitmap *pOldBitmap=CompatibleDC.SelectObject(&bitmap);
BITMAP bm;
bitmap.GetBitmap(&bm);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&CompatibleDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
dc.SelectObject(pOldBitmap);
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSalaryManagementDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
// Automation servers should not exit when a user closes the UI
// if a controller still holds on to one of its objects. These
// message handlers make sure that if the proxy is still in use,
// then the UI is hidden but the dialog remains around if it
// is dismissed.
void CSalaryManagementDlg::OnClose()
{
if (CanExit())
CDialog::OnClose();
}
void CSalaryManagementDlg::OnOK()
{
if (CanExit())
CDialog::OnOK();
}
void CSalaryManagementDlg::OnCancel()
{
if (CanExit())
CDialog::OnOK();
}
BOOL CSalaryManagementDlg::CanExit()
{
if (m_pAutoProxy != NULL)
{
ShowWindow(SW_HIDE);
return FALSE;
}
return TRUE;
}
void CSalaryManagementDlg::OnExit()
{
CDialog::OnOK();
}
void CSalaryManagementDlg::OnMin()
{
ShowWindow(SW_MINIMIZE);
}
HBRUSH CSalaryManagementDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_STATIC)
{
switch(pWnd->GetDlgCtrlID())
{
case IDC_ROLL:
{
pDC->SetBkColor(RGB(155,192,236));
pDC->SetBkMode(TRANSPARENT);
return CreateSolidBrush(RGB(155,192,236));
}
case IDC_SALARY:
case IDC_PASSWORD_MODIFY:
return hbr;
case IDC_STATIC13:
pDC->SetBkMode(TRANSPARENT);
return CreateSolidBrush(RGB(97,148,221));
default:
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
}
}
return hbr;
}
BOOL CSalaryManagementDlg::PreTranslateMessage(MSG* pMsg)
{
// if(m_tooltip)
// m_tooltip.RelayEvent(pMsg); //提示信息
return CDialog::PreTranslateMessage(pMsg);
}
void CSalaryManagementDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
//捕捉鼠标
if((GetCapture() != this)&& GetActiveWindow() !=NULL)
SetCapture();
else ReleaseCapture();
PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(point.x,point.y));
CRect rect;
GetClientRect(rect);
CDialog::OnLButtonDown(nFlags, point);
}
void CSalaryManagementDlg::OnTimer(UINT nIDEvent)
{
static int index=0;
CString str="",temp;
temp=_T("欢迎使用工资管理系统!!!");
//设置滚动字幕
GetDlgItem(IDC_ROLL)->Invalidate();
CString space=" ";
int length=temp.GetLength();
index=++index%length;
for(int i=1;i<index;i++)
temp=space+temp;
SetDlgItemText(IDC_ROLL,temp);
CDialog::OnTimer(nIDEvent);
}
void CSalaryManagementDlg::OnDestroy()
{
CDialog::OnDestroy();
USkinRestoreSkin();
}
//extern CStaffDlg* m_dlg;
//人事信息管理
void CSalaryManagementDlg::OnPesonal()
{
m_dlg=new CStaffDlg;
OpenDialog(m_dlg);
}
//工资管理
void CSalaryManagementDlg::OnSalary()
{
m_dlg=new CSalaryDlg;
OpenDialog(m_dlg);
}
//考勤管理
void CSalaryManagementDlg::OnAttendance()
{
m_dlg=new CKaoqinDlg;
OpenDialog(m_dlg);
}
//密码修改
void CSalaryManagementDlg::OnPassworChange()
{
// CDialog *dlg=new CPasswordSetDlg;
m_dlg=new CPasswordSetDlg;
OpenDialog(m_dlg);
}
//系统设置
void CSalaryManagementDlg::OnSystemSet()
{
m_dlg=new CSystemSetDlg;
OpenDialog(m_dlg);
}
//数据库备份与恢复
void CSalaryManagementDlg::OnBackupAndResume()
{
m_dlg=new CBackupRecovery;
OpenDialog(m_dlg);
}
//打开各模块对应的对话框
void CSalaryManagementDlg::OpenDialog(CDialog *dlg)
{
USkinRestoreSkin();
AnimateWindow(GetSafeHwnd(),300,AW_CENTER|AW_HIDE);
ShowWindow(SW_HIDE);
SetWindowPos(&wndBottom,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW );
dlg->DoModal();
delete dlg;
}
void CSalaryManagementDlg::OnStatic5()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -