帮我改下程序
// 33.cpp : Defines the class behaviors for the application.//
#include "stdafx.h"
#include "33.h"
#include "33Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMy33App
BEGIN_MESSAGE_MAP(CMy33App, CWinApp)
//{{AFX_MSG_MAP(CMy33App)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CMy33App construction
CMy33App::CMy33App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CMy33App object
CMy33App theApp;
/////////////////////////////////////////////////////////////////////////////
// CMy33App initialization
BOOL CMy33App::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
CMy33Dlg 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;
}
// 33Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "33.h"
#include "33Dlg.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()
/////////////////////////////////////////////////////////////////////////////
// CMy33Dlg dialog
CMy33Dlg::CMy33Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMy33Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMy33Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMy33Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMy33Dlg)
DDX_Control(pDX, IDOK, m_a);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMy33Dlg, CDialog)
//{{AFX_MSG_MAP(CMy33Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy33Dlg message handlers
BOOL CMy33Dlg::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
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMy33Dlg::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 CMy33Dlg::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);
static int t;
t++;
//for(int t=0;t<1000;t++)
//{
// for(int m=0;m<1000;m++)
// {
CPen pGrayPen(PS_SOLID, 0, RGB(0,0,0));
CPen pPen(PS_DASH, 0, RGB(0,0,0));
CBrush brush(RGB(0,0,0));
CBrush greenbrush(RGB(0,255,0));
CBrush redbrush(RGB(255,0,0));
CBrush yellowbrush(RGB(255,255,0));
dc.SelectObject(pGrayPen);
dc.MoveTo(200,30);
dc.LineTo(200,150);
dc.MoveTo(30,150);
dc.LineTo(200,150);
dc.MoveTo(30,350);
dc.LineTo(200,350);
dc.MoveTo(200,350);
dc.LineTo(200,470);
dc.MoveTo(400,30);
dc.LineTo(400,150);
dc.MoveTo(570,150);
dc.LineTo(400,150);
dc.MoveTo(570,350);
dc.LineTo(400,350);
dc.MoveTo(400,470);
dc.LineTo(400,350);
dc.SelectObject(pPen);
dc.MoveTo(300,470);
dc.LineTo(300,350);
dc.MoveTo(30,250);
dc.LineTo(200,250);
dc.MoveTo(300,30);
dc.LineTo(300,150);
dc.MoveTo(400,250);
dc.LineTo(570,250);
dc.TextOut(50,50,"N");
dc.SelectObject(pGrayPen);
int time;
time=(t/100)%18; int z;
static int x[20];
if(18-time>=10)
{
char str[8];
sprintf(str,"倒计时%0d",18-time);
dc.TextOut(224,40,str,8);
}
if(18-time<10)
{
char str[8];
sprintf(str,"倒计时%0d",18-time);
dc.TextOut(224,40,str,7);
}
if(t==1)
{
x[0]=200-(rand()%(75-50)+50);
for( z=0;z<9;z++)
{
x[z+1]=x[z]-(rand()%(250-100)+100);
}
};
if(time<6)
{
dc.SelectObject (&greenbrush);
dc.Ellipse(170,350,200,380);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z=0;z<10;z++)
{
dc.Rectangle(x[z],315,x[z]+60,275);
x[z]=x[z]+3;
if(x[z]>600)
{
if(z==0)
x[z]=x[9]-(rand()%(250-100)+100);
else
x[z]=x[z-1]-(rand()%(250-100)+100);
}
}
}
else
if(time>=6&&time<12)
{
dc.SelectObject(&yellowbrush);
dc.Ellipse(170,350,200,380);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z=0;z<10;z++)
{
if(x[z]+60>200)
{
dc.Rectangle(x[z],315,x[z]+60,275);
x[z]=x[z]+3;
if(x[z]>600)
{
if(z==0)
x[z]=x[9]-(rand()%(250-100)+100);
else
x[z]=x[z-1]-(rand()%(250-100)+100);
}
}
else
dc.Rectangle(x[z],315,x[z]+60,275);
}
}
else
{
dc.SelectObject(&redbrush);
dc.Ellipse(170,350,200,380);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z=0;z<10;z++)
{
if(x[z]+60>200)
{
dc.Rectangle(x[z],315,x[z]+60,275);
x[z]=x[z]+3;
if(x[z]>600)
{
if(z==0)
x[z]=x[9]-(rand()%(250-100)+100);
else
x[z]=x[z-1]-(rand()%(250-100)+100);
}
}
dc.Rectangle(x[z],315,x[z]+60,275);
}
}
static int x1[20];
int z1;
if(t==1)
{
x1[0]=400+(rand()%(75-50)+50);
for( z1=0;z1<9;z1++)
{
x1[z1+1]=x1[z1]+(rand()%(250-100)+100);
}
};
if(time<6)
{
dc.SelectObject (&greenbrush);
dc.Ellipse(400,120,430,150);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z1=0;z1<10;z1++)
{
dc.Rectangle(x1[z1],225,x1[z1]+60,185);
x1[z1]=x1[z1]-3;
if(x1[z1]<0)
{
if(z1==0)
x1[z1]=x1[9]+(rand()%(250-100)+100);
else
x1[z1]=x1[z1-1]+(rand()%(250-100)+100);
}
}
}
else
if(time>=6&&time<12)
{
dc.SelectObject(&yellowbrush);
dc.Ellipse(400,120,430,150);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z1=0;z1<10;z1++)
{
if(x1[z1]<400)
{
dc.Rectangle(x1[z1],225,x1[z1]+60,185);
x1[z1]=x1[z1]-3;
if(x1[z1]<0)
{
if(z1==0)
x1[z1]=x1[9]+(rand()%(250-100)+100);
else
x1[z1]=x1[z1-1]+(rand()%(250-100)+100);
}
}
else
dc.Rectangle(x1[z1],225,x1[z1]+60,185);
}
}
else
{
dc.SelectObject(&redbrush);
dc.Ellipse(400,120,430,150);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z1=0;z1<10;z1++)
{
if(x1[z1]<400)
{
dc.Rectangle(x1[z1],225,x1[z1]+60,185);
x1[z1]=x1[z1]-3;
if(x1[z1]<0)
{
if(z1==0)
x1[z1]=x1[9]+(rand()%(250-100)+100);
else
x1[z1]=x1[z1-1]+(rand()%(250-100)+100);
}
}
else
dc.Rectangle(x1[z1],225,x1[z1]+60,185);
}
}
static int x2[20];
int z2;
if(t==1)
{
x2[0]=150-(rand()%(75-50)+50);
for( z2=0;z2<9;z2++)
{
x2[z2+1]=x2[z2]-(rand()%(250-100)+100);
}
};
if(time<6)
{
dc.SelectObject(&redbrush);
dc.Ellipse(170,120,200,150);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z2=0;z2<10;z2++)
{
if(x2[z2]>150)
{
dc.Rectangle(225,x2[z2],265,x2[z2]-60);
x2[z2]=x2[z2]+3;
if(x2[z2]>500)
{
if(z2==0)
x2[z2]=x2[9]-(rand()%(250-100)+100);
else
x2[z2]=x2[z2-1]-(rand()%(250-100)+100);
}
}
else
dc.Rectangle(225,x2[z2],265,x2[z2]-60);
}
}
else
if(time>=6&&time<12)
{
dc.SelectObject (&greenbrush);
dc.Ellipse(170,120,200,150);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z2=0;z2<10;z2++)
{
dc.Rectangle(225,x2[z2],265,x2[z2]-60);
x2[z2]=x2[z2]+3;
if(x2[z2]>500)
{
if(z2==0)
x2[z2]=x2[9]-(rand()%(250-100)+100);
else
x2[z2]=x2[z2-1]-(rand()%(250-100)+100);
}
}
}
else
{
dc.SelectObject(&yellowbrush);
dc.Ellipse(170,120,200,150);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z2=0;z2<10;z2++)
{
if(x2[z2]>150)
{
dc.Rectangle(225,x2[z2],265,x2[z2]-60);
x2[z2]=x2[z2]+3;
if(x2[z2]>500)
{
if(z2==0)
x2[z2]=x2[9]-(rand()%(250-100)+100);
else
x2[z2]=x2[z2-1]-(rand()%(250-100)+100);
}
//x[z]=x[(z+9)%9]+(rand()%(250-100)+100);
}
else
dc.Rectangle(225,x2[z2],265,x2[z2]-60);
}
}
static int x3[20];
int z3;
if(t==1)
{
x3[0]=350+(rand()%(75-50)+50);
for( z3=0;z3<9;z3++)
{
x3[z3+1]=x3[z3]+(rand()%(250-100)+100);
}
};
if(time<6)
{
dc.SelectObject(&redbrush);
dc.Ellipse(400,350,430,380);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z3=0;z3<10;z3++)
{
if(x3[z3]-60<350)
{
dc.Rectangle(335,x3[z3],375,x3[z3]-60);
x3[z3]=x3[z3]-3;
if(x3[z3]-60<0)
{
if(z3==0)
x3[z3]=x3[9]+(rand()%(250-100)+100);
else
x3[z3]=x3[z3-1]+(rand()%(250-100)+100);
}
}
else
dc.Rectangle(335,x3[z3],375,x3[z3]-60);
}
}
else
if(time>=6&&time<12)
{
dc.SelectObject (&greenbrush);
dc.Ellipse(400,350,430,380);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z3=0;z3<10;z3++)
{
dc.Rectangle(335,x3[z3],375,x3[z3]-60);
x3[z3]=x3[z3]-3;
if(x3[z3]-60<0)
{
if(z3==0)
x3[z3]=x3[9]+(rand()%(250-100)+100);
else
x3[z3]=x3[z3-1]+(rand()%(250-100)+100);
}
}
}
else
{
dc.SelectObject(&yellowbrush);
dc.Ellipse(400,350,430,380);
dc.SelectObject(pGrayPen);
dc.SelectObject (&brush);
for( z3=0;z3<10;z3++)
{
if(x3[z3]-60<350)
{
dc.Rectangle(335,x3[z3],375,x3[z3]-60);
x3[z3]=x3[z3]-3;
if(x3[z3]-60<0)
{
if(z3==0)
x3[z3]=x3[9]+(rand()%(250-100)+100);
else
x3[z3]=x3[z3-1]+(rand()%(250-100)+100);
}
}
else
dc.Rectangle(335,x3[z3],375,x3[z3]-60);
}
}
CRect rect;
GetClientRect(&rect);
CRect rect1(0,120,rect.Width(),380);
CRect rect2(200,0,400,rect.Height());
Sleep(10);
if(m%2==0)
{
InvalidateRect(rect1,1);
InvalidateRect(rect2,1);
}
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy33Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMy33Dlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
//DEL void CMy33Dlg::StartandSuspend()
//DEL {
//DEL
//DEL }1
void CMy33Dlg::OnOK()
{
m++;
CRect rect;
GetClientRect(&rect);
CRect rect1(0,120,rect.Width(),380);
CRect rect2(170,0,430,rect.Height());
InvalidateRect(rect1,1);
InvalidateRect(rect2,1);
if(m%2==0)
m_a.SetWindowText("暂停");
else
m_a.SetWindowText("开始");
// TODO: Add extra validation here
//CDialog::OnOK();
}
// stdafx.cpp : source file that includes just the standard includes
// 33.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"