📄 dialognavigate.cpp
字号:
// DialogNavigate.cpp : implementation file
//
#include "stdafx.h"
#include "HomeFinanceManager.h"
#include "DialogNavigate.h"
#include "NavigateView.h"
#include "SysStatus.h"
#include "DBOperator.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogNavigate dialog
CDialogNavigate::CDialogNavigate(CWnd* pParent /*=NULL*/)
: CDialog(CDialogNavigate::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogNavigate)
m_strUserName = _T("");
//}}AFX_DATA_INIT
m_pParentView = NULL;
}
void CDialogNavigate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogNavigate)
DDX_Control(pDX, IDC_EXIT, m_btnExit);
DDX_Control(pDX, IDC_USERIMG, m_btnUserImg);
DDX_Control(pDX, IDC_BTN_LOGIN, m_btnLogin);
DDX_Control(pDX, IDC_BTN_FINANCEOUT, m_btnFinanceOut);
DDX_Control(pDX, IDC_BTN_FINANCEIN, m_btnFinance);
DDX_Control(pDX, IDC_BTN_BALANCE, m_btnBalance);
DDX_Text(pDX, IDC_USERNAME, m_strUserName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogNavigate, CDialog)
//{{AFX_MSG_MAP(CDialogNavigate)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
ON_WM_ERASEBKGND()
ON_BN_CLICKED(IDC_BTN_LOGIN, OnBtnLogin)
ON_BN_CLICKED(IDC_BTN_BALANCE, OnBtnBalance)
ON_BN_CLICKED(IDC_BTN_FINANCEIN, OnBtnFinancein)
ON_BN_CLICKED(IDC_BTN_FINANCEOUT, OnBtnFinanceout)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_USERIMG, OnUserimg)
ON_BN_CLICKED(IDC_EXIT, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogNavigate message handlers
void CDialogNavigate::OnOK( )
{
}
void CDialogNavigate::DispalyBackBmp(CDC* pDC)
{
CBitmap Bitmap;
Bitmap.LoadBitmap(IDB_NAVIGATE);
BITMAP bmpInfo;
Bitmap.GetBitmap(&bmpInfo);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
MemDC.SelectObject(Bitmap);
RECT rcClient;
this->GetClientRect(&rcClient);
int iWidth = rcClient.right - rcClient.left;
int iHeight = rcClient.bottom - rcClient.top;
pDC->BitBlt(0, 0, iWidth, iHeight, &MemDC, 0, 0,SRCCOPY);
}
void CDialogNavigate::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CDialogNavigate::OnEraseBkgnd( CDC* pDC )
{
DispalyBackBmp(pDC);
return TRUE;
}
HBRUSH CDialogNavigate::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
//改变控件的颜色
if(nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);
LOGBRUSH logBrush;
logBrush.lbStyle = BS_HOLLOW;
hbr = CreateBrushIndirect(&logBrush);
}
if(nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetTextColor(RGB(255,0,0));//字体色
pDC->SetBkColor(RGB(170, 243, 162));
}
return hbr;
}
void CDialogNavigate::setParentView(CNavigateView* pView)
{
m_pParentView = pView;
}
void CDialogNavigate::OnBtnLogin()
{
// TODO: Add your control notification handler code here
m_pParentView->Login();
}
void CDialogNavigate::OnBtnBalance()
{
// TODO: Add your control notification handler code here
if(gSysStatus.getLoginStatus() == FALSE)
{
AfxMessageBox("用户尚未登录,无法使用该系统!");
return;
}
m_pParentView->Balance();
}
void CDialogNavigate::OnBtnFinancein()
{
// TODO: Add your control notification handler code here
if(gSysStatus.getLoginStatus() == FALSE)
{
AfxMessageBox("用户尚未登录,无法使用该系统!");
return;
}
m_pParentView->FinanceIn();
}
void CDialogNavigate::OnBtnFinanceout()
{
// TODO: Add your control notification handler code here
if(gSysStatus.getLoginStatus() == FALSE)
{
AfxMessageBox("用户尚未登录,无法使用该系统!");
return;
}
m_pParentView->FinanceOut();
}
void CDialogNavigate::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
m_strUserName = gSysStatus.getUserName();
this->UpdateData(FALSE);
}
void CDialogNavigate::setCurrUser(CString& strUserName)
{
m_strUserName.Format("用户%s正在使用中", strUserName.GetBuffer(0));
UpdateData(FALSE);
char* pImgData = 0;
int iDataLen;
gDBOperator.getUserImg(strUserName, &pImgData, iDataLen);
if(pImgData)
{
m_btnUserImg.setBmpData(pImgData, iDataLen);
delete[] pImgData;
}
}
void CDialogNavigate::OnUserimg()
{
// TODO: Add your control notification handler code here
/*m_btnUserImg.OpenBmpFile();
char* pData = NULL;
int iDataLength;
m_btnUserImg.getData(NULL, iDataLength);
pData = new char[iDataLength];
m_btnUserImg.getData(pData, iDataLength);
gDBOperator.addUser("wyx", "beyourself", pData, iDataLength);
delete[] pData;*/
}
void CDialogNavigate::OnExit()
{
// TODO: Add your control notification handler code here
CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd( );
pWnd->OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -