📄 dlaytest2dlg.cpp
字号:
// DlayTest2Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "DlayTest.h"
#include "DlayTest2Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlayTest2Dlg dialog
CDlayTest2Dlg::CDlayTest2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CDlayTest2Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlayTest2Dlg)
m_GetNum = 0;
//}}AFX_DATA_INIT
m_brush0.CreateSolidBrush(RGB(45, 122, 255));//设置笔刷
}
void CDlayTest2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlayTest2Dlg)
DDX_Control(pDX, IDC_PROGRESS_TIMER, m_ProgressTimer);
DDX_Text(pDX, IDC_GETNUM, m_GetNum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlayTest2Dlg, CDialog)
//{{AFX_MSG_MAP(CDlayTest2Dlg)
ON_BN_CLICKED(IDC_START2, OnStart2)
ON_WM_CTLCOLOR()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlayTest2Dlg message handlers
void CDlayTest2Dlg::OnStart2()
{
// TODO: Add your control notification handler code here
PushNum=0;
CountNum=0;
m_GetNum=0;
UpdateData(false);
SetTimer(1,500,NULL);
GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_SHOW);
}
BOOL CDlayTest2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_BitmapBt1.LoadBitmaps(IDB_BITMAP3,IDB_BITMAP4,IDB_BITMAP3);
VERIFY(m_BitmapBt1.SubclassDlgItem(IDC_BUTTON1,this));
m_BitmapBt1.SizeToContent();
GetDlgItem(IDC_BUTTON1) -> ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
HBRUSH CDlayTest2Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return m_brush0;
}
void CDlayTest2Dlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
int Posx,Posy;
CountNum++;
m_ProgressTimer.SetRange(0,50);
m_ProgressTimer.SetPos(CountNum);
if(CountNum<=50)
{
Posx=rand()%284;
Posy=rand()%300;
GetDlgItem(IDC_BUTTON1)->MoveWindow( CRect(Posx,Posy,Posx+86,Posy+70) );
}
else
{
KillTimer(1);
GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE);
}
CDialog::OnTimer(nIDEvent);
}
void CDlayTest2Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
PushNum++;
m_GetNum=PushNum;
UpdateData(false);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -