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

📄 clockdlg.cpp

📁 数码管、模拟表、数字表、闹铃、秒表计时、倒计时、动画图标、闪烁窗口等功能
💻 CPP
字号:
// ClockDlg.cpp : implementation file
//

#include "stdafx.h"
#include "0510210204watch.h"
#include "ClockDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CClockDlg dialog


CClockDlg::CClockDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CClockDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CClockDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}


void CClockDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClockDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CClockDlg, CDialog)
	//{{AFX_MSG_MAP(CClockDlg)
	ON_WM_DESTROY()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClockDlg message handlers

void CClockDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	KillTimer(1);
}

void CClockDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
    CTime time =CTime::GetCurrentTime();
	int  year,y1,y2,y3,y4;
	 year=time.GetYear();
	 y1=year/1000;
	 y2=year/100%10;
	 y3=year/10%10;
	 y4= year%10;
	Output(y1,0);
	Output(y2,1);
	Output(y3,2);
	Output(y4,3);
	Output(10,4); 
	int month=time.GetMonth();
	int m1=month/10,m2=month%10;
	Output(m1,5);Output(m2,6);Output(11,7);
	int day=time.GetDay();
	int d1=day/10,d2=day%10;
	Output(d1,8);Output(d2,9);Output(12,10);
	int hour=time.GetHour();
	int h1=hour/10,h2=hour%10;
	Output(h1,11);Output(h2,12);Output(13,13);
	int minute=time.GetMinute();
	int mi1=minute/10,mi2=minute%10;
	Output(mi1,14);Output(mi2,15);Output(13,16);
	int sec=time.GetSecond();
	int s1=sec/10,s2=sec%10;
	Output(s1,17);Output(s2,18);
	CDialog::OnTimer(nIDEvent);
}

BOOL CClockDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetTimer(1,1000,NULL);
	CRect rectclock;
	GetClientRect(&rectclock);
	GetWindowRect(&windowrect);
	m_h = rectclock.Height();
	m_w = rectclock.Width()/18;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CClockDlg::Output(UINT digit, UINT pos)
{
	CClientDC dc(this);
	CDC MemDC;
	MemDC.CreateCompatibleDC(&dc);
	CBitmap mBitmap;
	UINT  IDbitmap[]={IDB_BITMAP1, IDB_BITMAP2, IDB_BITMAP3, IDB_BITMAP4, IDB_BITMAP5 , IDB_BITMAP6,  IDB_BITMAP7, IDB_BITMAP8, IDB_BITMAP9, IDB_BITMAP10, IDB_BITMAP11, IDB_BITMAP12, IDB_BITMAP13, IDB_BITMAP14};
	mBitmap.LoadBitmap(IDbitmap[digit]); 
	BITMAP BM;
	mBitmap.GetObject(sizeof(BM),&BM);
	int mBitmapWidth=BM.bmWidth;
	int mBitmapHeight=BM.bmHeight;
	CBitmap*pOldBitmap=MemDC.SelectObject(&mBitmap);
    dc.StretchBlt(m_w*pos, 0, m_w, m_h,	&MemDC, 0, 0, mBitmapWidth, mBitmapHeight, SRCCOPY);
 	MemDC.SelectObject(pOldBitmap);	
}

⌨️ 快捷键说明

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