📄 pandlg1.cpp
字号:
// PanDlg1.cpp : implementation file
//
#include "stdafx.h"
#include "LaneSoft.h"
#include "PanDlg1.h"
#include "IniData.h"
#include "LaneSoftDoc.h"
#include "LaneSoftView.h"
#include "OperateDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CIniData theIniData;
extern CLaneSoftView * m_pMainView;
/////////////////////////////////////////////////////////////////////////////
// CPanDlg1 dialog
CPanDlg1::CPanDlg1(CWnd* pParent /*=NULL*/)
: CDialog(CPanDlg1::IDD, pParent)
{
//{{AFX_DATA_INIT(CPanDlg1)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pMemDC = new CDC;
}
void CPanDlg1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPanDlg1)
DDX_Control(pDX, IDC_CLOCK, m_cClock);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPanDlg1, CDialog)
//{{AFX_MSG_MAP(CPanDlg1)
ON_WM_CREATE()
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPanDlg1 message handlers
int CPanDlg1::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_rect.left = 799-113;
m_rect.top = 599-181;
m_rect.right = 799;
m_rect.bottom = 599;
m_wndpl.length = sizeof(WINDOWPLACEMENT);
m_wndpl.flags = 0;
m_wndpl.showCmd = SW_SHOW;
m_wndpl.rcNormalPosition = m_rect;
SetWindowPlacement(&m_wndpl);
CDC *pdc = GetDC();
m_pMemDC->CreateCompatibleDC(pdc);
ReleaseDC(pdc);
SetTimer(IDT_TIMER,1000,NULL);
return 0;
}
void CPanDlg1::OnPaint()
{
CPaintDC dc(this); // device context for painting
DWORD old_bkcolor;
DWORD old_textcolor,DateColor;
int old_textmode,day;
CFont * pOldFont;
CString str;
m_tDate = CTime::GetCurrentTime();
CDC *pdc = GetDC();
CBitmap Bitmap;
Bitmap.LoadBitmap(IDB_BITMAP3);
CBitmap * pOldBitmap = m_pMemDC->SelectObject(&Bitmap);
pdc->BitBlt(0,35,113,171,m_pMemDC,0,0,SRCCOPY);
old_textcolor = pdc->SetTextColor(theIniData.m_dColor_Text1);
old_bkcolor = pdc->SetBkColor(theIniData.m_dColor_Text1);
old_textmode = pdc->SetBkMode(TRANSPARENT);
pOldFont = pdc->SelectObject(&theIniData.m_fFont2);
pdc->TextOut(5,61,m_tDate.Format("%Y年%m月"));
switch(m_tDate.GetDayOfWeek())
{
case 1:
str = "星期日";
DateColor = theIniData.m_dColor_Text5;
break;
case 2:
str = "星期一";
DateColor = theIniData.m_dColor_Text3;
break;
case 3:
str = "星期二";
DateColor = theIniData.m_dColor_Text3;
break;
case 4:
str = "星期三";
DateColor = theIniData.m_dColor_Text3;
break;
case 5:
str = "星期四";
DateColor = theIniData.m_dColor_Text3;
break;
case 6:
str = "星期五";
DateColor = theIniData.m_dColor_Text3;
break;
case 7:
str = "星期六";
DateColor = theIniData.m_dColor_Text2;
break;
}
pdc->TextOut(25,155,str);
pdc->SetTextColor(DateColor);
// pdc->SetTextColor(theIniData.m_dColor_Text2);
pdc->SelectObject(&theIniData.m_fFont1);
day = m_tDate.GetDay();
str.Format("%d",day);
if(str.GetLength()==2)
pdc->TextOut(30,95,str);
else
pdc->TextOut(45,95,str);
pdc->SelectObject(pOldFont);
pdc->SetBkColor(old_bkcolor);
pdc->SetTextColor(old_textcolor);
pdc->SetBkMode(old_textmode);
m_pMemDC->SelectObject(pOldBitmap);
ReleaseDC(pdc);
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
CPanDlg1::~CPanDlg1()
{
delete m_pMemDC;
}
void CPanDlg1::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(nIDEvent == IDT_TIMER)
{
m_tTime = CTime::GetCurrentTime();
if(m_tTime.GetDay() != m_tDate.GetDay())
Invalidate();
m_cClock.SetWindowText(m_tTime.Format("%H:%M:%S"));
}
m_pMainView->m_pOperateDlg->TVShowTime();
CDialog::OnTimer(nIDEvent);
}
BOOL CPanDlg1::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
KillTimer(IDT_TIMER);
return CDialog::DestroyWindow();
}
HBRUSH CPanDlg1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
pDC->SelectObject(&theIniData.m_fFont2);
pDC->SetTextColor(theIniData.m_dColor_Text4);
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -