| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 455 人关注过本帖
标题:color
只看楼主 加入收藏
coding
Rank: 1
等 级:新手上路
威 望:1
帖 子:60
专家分:0
注 册:2007-9-30
收藏
 问题点数:0 回复次数:0 
color

//这个程序运行后,在窗口中央出现一个
//绿色的小三角形,并且不断地旋转
//以下是主应用程序文件
#include "File.h"
#include "math.h"

BEGIN_MESSAGE_MAP(CFileWnd,CFrameWnd) //
ON_WM_PAINT()
ON_WM_TIMER()
END_MESSAGE_MAP()

void CFileWnd::OnPaint()
{
CFrameWnd::OnPaint();
OnShow();
}

CFileWnd::CFileWnd()
{
angle=0;
}

void CFileWnd::OnShow()
{
CClientDC dc(this);
CRect rc;
CPoint poi;
GetClientRect(&rc);
poi.x=GetRand(rc.right);
poi.y=GetRand(rc.bottom);
poi.x=(rc.left+rc.right)/2;
poi.y=(rc.top+rc.bottom)/2;
radius=100;
CRect rc1;
rc1.left=poi.x-radius;
rc1.top=poi.y-radius;
rc1.right=poi.x+radius;
rc1.bottom=poi.y+radius;

for(int i=0;i<3;i++)
{
point[i].x=poi.x-radius*sin(angle);
point[i].y=poi.y-radius*cos(angle);
angle+=2*3.1415926/3;
}

CBrush brush(RGB(120,255,0));
CBrush* oldbrush;
oldbrush=dc.SelectObject(&brush);

dc.SetPolyFillMode(WINDING);
dc.Polygon(point,3);

dc.SelectObject(oldbrush);

ReleaseDC(&dc);

}


int CFileWnd::GetRand(int nRand)
{

float nang=(float)rand()/RAND_MAX;
float nconst=(float)nRand*nang;
return (float)nconst;
}


void CFileWnd::OnTimer(UINT nIDEvent)
{
angle+=2*3.1415926/100;
angle=fmod(angle,2*3.1415926);
Invalidate();
}
BOOL CFileApp::InitInstance()
{
CFileWnd* pFrame=new CFileWnd;
pFrame->Create(0,"coding");
pFrame->ShowWindow(SW_SHOWNORMAL);
pFrame->UpdateData();
pFrame->SetTimer(1,20,NULL);
this->m_pMainWnd=pFrame;
return TRUE;
}

CFileApp theApp;

搜索更多相关主题的帖子: 应用程序 include 三角形 color angle 
2007-10-12 13:20
快速回复:color
数据加载中...
 
   



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

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