代码
exp1.cpp
// exp1.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "exp1.h"
#include "exp1Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExp1App
BEGIN_MESSAGE_MAP(CExp1App, CWinApp)
//{{AFX_MSG_MAP(CExp1App)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExp1App construction
CExp1App::CExp1App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CExp1App object
CExp1App theApp;
/////////////////////////////////////////////////////////////////////////////
// CExp1App initialization
BOOL CExp1App::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CExp1Dlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
exp1Dlg.cpp
// exp1Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "exp1.h"
#include "exp1Dlg.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()
/////////////////////////////////////////////////////////////////////////////
// CExp1Dlg dialog
CExp1Dlg::CExp1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CExp1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CExp1Dlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CExp1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExp1Dlg)
DDX_Control(pDX, IDC_9, m_pic7);
DDX_Control(pDX, IDC_STATICC, m_tt);
DDX_Control(pDX, IDC_STATII, m_tm);
DDX_Control(pDX, IDC_SSs, m_pic6);
DDX_Control(pDX, IDC_STATI, m_pic5);
DDX_Control(pDX, IDC_ST, m_picc);
DDX_Control(pDX, IDC_S, m_pic);
DDX_Control(pDX, IDC_STAT, m_pic4);
DDX_Control(pDX, IDC_STA, m_pic3);
DDX_Control(pDX, IDC_2, m_pic2);
DDX_Control(pDX, IDC_1, m_pic1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExp1Dlg, CDialog)
//{{AFX_MSG_MAP(CExp1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_STA, OnSta)
ON_BN_CLICKED(IDC_S, OnS)
ON_NOTIFY(DTN_CLOSEUP, IDC_DATETIMEPICKER1, OnCloseupDatetimepicker1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExp1Dlg message handlers
BOOL CExp1Dlg::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
t = 0;
// TODO: Add extra initialization here
SetTimer(1,1000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CExp1Dlg::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 CExp1Dlg::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
{
CDialog::OnPaint();
}*/
CPaintDC dc(this);//用于画图的设备上下文
//加载背景位图
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP16);
CBrush brush(&bitmap);//建立画刷
dc.SelectObject(brush);
CRect rect;
GetClientRect(rect);//获得客户区大小
dc.Rectangle(rect);//画矩形,并用图片的画刷填充
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CExp1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CExp1Dlg::OnOK()
{
// TODO: Add extra validation here
s=0;
SetTimer(1,1000,NULL);//定义时钟1,时间间隔为1000ms
//CDialog::OnOK();
}
void CExp1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
KillTimer(1); //关闭1号定时器
}
void CExp1Dlg::OnButton2()
{
// TODO: Add your control notification handler code here
CBitmap bitmap; // CBitmap对象,用于加载位图
HBITMAP hBmp; // 保存CBitmap加载的位图的句柄
bitmap.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
void CExp1Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime m= CTime::GetCurrentTime(); //获取系统日期
CString tt;
s=s+1;
tt.Format("计时:%d秒",s);
m_tt.SetWindowText(tt);
CString tm;
tm.Format("%02d:%02d:%02d",m.GetHour(),m.GetMinute(),m.GetSecond());
SetDlgItemText(IDC_STATII,tm);
int ss=m.GetHour();
int t5,t6;
t5=ss%10;
t6=ss/10;
t5 = ss%10;
t6=ss/10;
CBitmap bitmap5; // CBitmap对象,用于加载位图
HBITMAP hBmp5; // 保存CBitmap加载的位图的句柄
if(t5 == 0)
{
bitmap5.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 1)
{
bitmap5.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 2)
{
bitmap5.LoadBitmap(IDB_BITMAP2); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 3)
{
bitmap5.LoadBitmap(IDB_BITMAP3); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 4)
{
bitmap5.LoadBitmap(IDB_BITMAP4); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 5)
{
bitmap5.LoadBitmap(IDB_BITMAP5); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 6)
{
bitmap5.LoadBitmap(IDB_BITMAP6); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 7)
{
bitmap5.LoadBitmap(IDB_BITMAP7); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 8)
{
bitmap5.LoadBitmap(IDB_BITMAP8); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t5 == 9)
{
bitmap5.LoadBitmap(IDB_BITMAP9); // 将位图IDB_BITMAP1加载到bitmap
hBmp5 = (HBITMAP)bitmap5.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic5.SetBitmap(hBmp5); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
CBitmap bitmap6; // CBitmap对象,用于加载位图
HBITMAP hBmp6; // 保存CBitmap加载的位图的句柄
if(t6 == 0)
{
bitmap6.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp6 = (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 1)
{
bitmap6.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp6 = (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 2)
{
bitmap6.LoadBitmap(IDB_BITMAP2); // 将位图IDB_BITMAP1加载到bitmap
hBmp6= (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 3)
{
bitmap6.LoadBitmap(IDB_BITMAP3); // 将位图IDB_BITMAP1加载到bitmap
hBmp6= (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 4)
{
bitmap6.LoadBitmap(IDB_BITMAP4); // 将位图IDB_BITMAP1加载到bitmap
hBmp6= (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 5)
{
bitmap6.LoadBitmap(IDB_BITMAP5); // 将位图IDB_BITMAP1加载到bitmap
hBmp6= (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 6)
{
bitmap6.LoadBitmap(IDB_BITMAP6); // 将位图IDB_BITMAP1加载到bitmap
hBmp6= (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 7)
{
bitmap6.LoadBitmap(IDB_BITMAP7); // 将位图IDB_BITMAP1加载到bitmap
hBmp6= (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 8)
{
bitmap6.LoadBitmap(IDB_BITMAP8); // 将位图IDB_BITMAP1加载到bitmap
hBmp6 = (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t6 == 9)
{
bitmap6.LoadBitmap(IDB_BITMAP9); // 将位图IDB_BITMAP1加载到bitmap
hBmp6 = (HBITMAP)bitmap6.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic6.SetBitmap(hBmp6); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
int mm=m.GetMinute();
int t3,t4;
t3=mm%10;
CBitmap bitmap3; // CBitmap对象,用于加载位图
HBITMAP hBmp3; // 保存CBitmap加载的位图的句柄
if(t3 == 0)
{
bitmap3.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 1)
{
bitmap3.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 2)
{
bitmap3.LoadBitmap(IDB_BITMAP2); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 3)
{
bitmap3.LoadBitmap(IDB_BITMAP3); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 4)
{
bitmap3.LoadBitmap(IDB_BITMAP4); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 5)
{
bitmap3.LoadBitmap(IDB_BITMAP5); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 6)
{
bitmap3.LoadBitmap(IDB_BITMAP6); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 7)
{
bitmap3.LoadBitmap(IDB_BITMAP7); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 8)
{
bitmap3.LoadBitmap(IDB_BITMAP8); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t3 == 9)
{
bitmap3.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp3 = (HBITMAP)bitmap3.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic3.SetBitmap(hBmp3); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
CBitmap bitmap4; // CBitmap对象,用于加载位图
HBITMAP hBmp4; // 保存CBitmap加载的位图的句柄
t4=mm/10;
if(t4 == 0)
{
bitmap4.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 1)
{
bitmap4.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 2)
{
bitmap4.LoadBitmap(IDB_BITMAP2); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 3)
{
bitmap4.LoadBitmap(IDB_BITMAP3); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 4)
{
bitmap4.LoadBitmap(IDB_BITMAP4); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 5)
{
bitmap4.LoadBitmap(IDB_BITMAP5); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 6)
{
bitmap4.LoadBitmap(IDB_BITMAP6); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 7)
{
bitmap4.LoadBitmap(IDB_BITMAP7); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 8)
{
bitmap4.LoadBitmap(IDB_BITMAP8); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t4 == 9)
{
bitmap4.LoadBitmap(IDB_BITMAP9); // 将位图IDB_BITMAP1加载到bitmap
hBmp4 = (HBITMAP)bitmap4.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic4.SetBitmap(hBmp4); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
int s=m.GetSecond(); //获取秒
int t1, t2;
t1 = s % 10;
t2=s/10;
CBitmap bitmap; // CBitmap对象,用于加载位图
HBITMAP hBmp; // 保存CBitmap加载的位图的句柄
if(t1 == 0)
{
bitmap.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 1)
{
bitmap.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 2)
{
bitmap.LoadBitmap(IDB_BITMAP2); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 3)
{
bitmap.LoadBitmap(IDB_BITMAP3); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 4)
{
bitmap.LoadBitmap(IDB_BITMAP4); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 5)
{
bitmap.LoadBitmap(IDB_BITMAP5); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 6)
{
bitmap.LoadBitmap(IDB_BITMAP6); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 7)
{
bitmap.LoadBitmap(IDB_BITMAP7); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 8)
{
bitmap.LoadBitmap(IDB_BITMAP8); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t1 == 9)
{
bitmap.LoadBitmap(IDB_BITMAP9); // 将位图IDB_BITMAP1加载到bitmap
hBmp = (HBITMAP)bitmap.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic1.SetBitmap(hBmp); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
CBitmap bitmap2; // CBitmap对象,用于加载位图
HBITMAP hBmp2; // 保存CBitmap加载的位图的句柄
if(t2 == 0)
{
bitmap2.LoadBitmap(IDB_BITMAP0); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 1)
{
bitmap2.LoadBitmap(IDB_BITMAP1); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 2)
{
bitmap2.LoadBitmap(IDB_BITMAP2); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 3)
{
bitmap2.LoadBitmap(IDB_BITMAP3); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 4)
{
bitmap2.LoadBitmap(IDB_BITMAP4); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 5)
{
bitmap2.LoadBitmap(IDB_BITMAP5); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 6)
{
bitmap2.LoadBitmap(IDB_BITMAP6); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 7)
{
bitmap2.LoadBitmap(IDB_BITMAP7); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 8)
{
bitmap2.LoadBitmap(IDB_BITMAP8); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
if(t2 == 9)
{
bitmap2.LoadBitmap(IDB_BITMAP9); // 将位图IDB_BITMAP1加载到bitmap
hBmp2 = (HBITMAP)bitmap2.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic2.SetBitmap(hBmp2); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
}
t = t + 1;
CBitmap bitmap7; // CBitmap对象,用于加载位图
HBITMAP hBmp7; // 保存CBitmap加载的位图的句柄
bitmap7.LoadBitmap(IDB_BITMAP10); // 将位图IDB_BITMAP1加载到bitmap
hBmp7 = (HBITMAP)bitmap7.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_pic.SetBitmap(hBmp7); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
CBitmap bitmap8; // CBitmap对象,用于加载位图
HBITMAP hBmp8; // 保存CBitmap加载的位图的句柄
bitmap8.LoadBitmap(IDB_BITMAP10); // 将位图IDB_BITMAP1加载到bitmap
hBmp8 = (HBITMAP)bitmap8.GetSafeHandle(); // 获取bitmap加载位图的句柄
m_picc.SetBitmap(hBmp8); // 设置图片控件m_jzmPicture的位图图片为IDB_BITMAP1
CDialog::OnTimer(nIDEvent);
}
void CExp1Dlg::OnSta()
{
// TODO: Add your control notification handler code here
}
void CExp1Dlg::OnS()
{
// TODO: Add your control notification handler code here
}
void CExp1Dlg::OnCloseupDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
然后运行
最终成品展示
如果需要完整代码可以给我留言~
我是热爱学习热爱编程的呵呵哒!
更多原创文章尽情期待!
个人知乎链接:https://www.zhihu.com/people/heheda-84-17/posts