| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 454 人关注过本帖
标题:书上的一个C++程序编译没错误,但得不到正确结果!!请各位大侠帮忙啊,讲详 ...
只看楼主 加入收藏
xuzhitao
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-6-17
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
书上的一个C++程序编译没错误,但得不到正确结果!!请各位大侠帮忙啊,讲详细点,本人还是个菜鸟
// Example1View.cpp : implementation of the CExample1View class
//每隔500ms生成一个随机大小,随机位置,随机颜色的实心圆,并显示在屏幕上。。

#include "stdafx.h"
#include "Example1.h"

#include "Example1Doc.h"
#include "Example1View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CExample1View

IMPLEMENT_DYNCREATE(CExample1View, CView)

BEGIN_MESSAGE_MAP(CExample1View, CView)
    //{{AFX_MSG_MAP(CExample1View)
    ON_WM_TIMER()
    ON_COMMAND(IDM_START, OnStart)
    //}}AFX_MSG_MAP
    // Standard printing commands
    ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
    ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExample1View construction/destruction

CExample1View::CExample1View()
{
    // TODO: add construction code here

}

CExample1View::~CExample1View()
{
}

BOOL CExample1View::PreCreateWindow(CREATESTRUCT& cs)
{
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs

    return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CExample1View drawing

void CExample1View::OnDraw(CDC* pDC)
{
    CExample1Doc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CExample1View printing

BOOL CExample1View::OnPreparePrinting(CPrintInfo* pInfo)
{
    // default preparation
    return DoPreparePrinting(pInfo);
}

void CExample1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
    // TODO: add extra initialization before printing
}

void CExample1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
    // TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CExample1View diagnostics

#ifdef _DEBUG
void CExample1View::AssertValid() const
{
    CView::AssertValid();
}

void CExample1View::Dump(CDumpContext& dc) const
{
    CView::Dump(dc);
}

CExample1Doc* CExample1View::GetDocument() // non-debug version is inline
{
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExample1Doc)));
    return (CExample1Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CExample1View message handlers

void CExample1View::OnTimer(UINT nIDEvent)
{
CDC*pDC=this->GetDC();    //pDC->SetPixel(rand()%800,rand()%600,RGB(rand()%256,rand()%256));
for(int i=0;i<100;i++){

    int x=rand()%1024;
    int y=rand()%768;
    int r=rand()%100;
    CBrush brush;
    brush.CreateSolidBrush(RGB(rand()%256,rand()%256,rand()%256));
    pDC->SelectObject(&brush);
    pDC->Ellipse(x,y,x+r,y+r);
    //pDC->Recrangle(x,y,x+r,y+r);
}// TODO: Add your message handler code here and/or call default
   
    CView::OnTimer(nIDEvent);
}


void CExample1View::OnStart()
{
this->SetTimer(1,500,NULL);    // TODO: Add your command handler code here
   
}
搜索更多相关主题的帖子: include 
2011-06-17 23:27
naruto01
Rank: 4
等 级:业余侠客
帖 子:103
专家分:280
注 册:2011-5-23
收藏
得分:14 
发到VC++版块效果应该更好
2011-06-17 23:38
xuzhitao
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-6-17
收藏
得分:0 
哦……谢谢!!第一次不是很了解。。。
2011-06-18 00:23
快速回复:书上的一个C++程序编译没错误,但得不到正确结果!!请各位大侠帮忙啊 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014175 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved