• 大小: 1.13MB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-09-03
  • 语言: C/C++
  • 标签: vc++  MFC  绘图  

资源简介

利用vc++MFC的绘图控件类绘制彩色五角星,可以直接运行的!

资源截图

代码片段和文件信息

#include
#include
#include
#include
#define PI 3.1415926
POINT infive[5]outfive[5]pp[2]lx[3]lx1[3]lx2[2];
int ijmnk=0;
double dfR0=250.0dfR1=(dfR0)*sin(0.1*PI)/sin(126.0/180*PI);
long WINAPI WndProc(HWND hWndUINT iMessageUINT wParamLONG lParam);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstanceint nCmdShow);

int WINAPI WinMain(HINSTANCE hInstanceHINSTANCE hPrevInstanceLPSTR lpCmdLineint nCmdShow)
{
MSG Message;
if(!InitWindowsClass(hInstance))
     return FALSE;
if(!InitWindows(hInstancenCmdShow))
     return FALSE;
while(GetMessage(&Message000))
{
         TranslateMessage(&Message);
 DispatchMessage(&Message);

}
  return Message.wParam;

}
long WINAPI WndProc(HWND hWndUINT iMessageUINT wParamLONG lParam)
{
HDC hDC;//定义指向设备描述表的句柄
HBRUSH hBrush;//定义指向画刷的句柄
HPEN hPen;
PAINTSTRUCT PtStr;
switch(iMessage)//处理消息
{
case WM_PAINT:
hDC=BeginPaint(hWnd&PtStr);
SetMapMode(hDCMM_ANISOTROPIC);
SetWindowOrgEx(hDC-400-300NULL);//
dfR0=k*10%250;
//dfR1=(dfR0)*sin(0.1*PI)/sin(126.0/180*PI);
hPen=(HPEN)GetStockobject(BLACK_PEN);
Selectobject(hDChPen);
for(i=0;i<5;i++)
{
outfive[i].x=(long)dfR0*cos(i*72.0/180*PI-0.1*PI);
    outfive[i].y=(long)dfR0*sin(i*72.0/180*PI-0.1*PI);
    infive[i].x=(long)dfR1*cos(i*72.9/180*PI-36.0/180*PI-18.0/180*PI);
    infive[i].y=(long)dfR1*sin(i*72.9/180*PI-36.0/180*PI-18.0/180*PI);
}
        Polygon(hDCoutfive5);
Polygon(hDCinfive5);

for(j=0;j<5;j++)//填充小三角形
{   
if(j==4)
{
lx[0]=outfive[j];
    lx[1]=infive[j];
lx[2]=infive[0];
}
else

{
lx[0]=outfive[j];
    lx[1]=infive[j];
lx[2]=infive[j+1];
}

hBrush=CreateSolidBrush(RGB(188-j*20%255j*50%255255-j*40%255));
        Selectobject(hDChBrush);
Polygon(hDClx3);
}
//
for(j=0;j<5;j++)//填充大三角形
{   
if(j==0)
{
lx1[0]=infive[j];
    lx1[1]=outfive[j];
lx1[2]=outfive[4];
}
else

{
lx1[0]=infive[j];
    lx1[1]=outfive[j];
lx1[2]=outfive[j-1];
}

hBrush=CreateSolidBrush(RGB(128+j*40%255j*50%255128-j*37%255));
        Selectobject(hDChBrush);
Polygon(hDClx13);
}
        hBrush=CreateSolidBrush(RGB(160160164));
        Selectobject(hDChBrush);
        Polygon(hDCinfive5);//填充小五边形

for(i=0;i<5;i++)                     //画大五边形边线
{
if(i==4)
{
lx2[0]=outfive[4];
    lx2[1]=outfive[0];
}
else
{
lx2[0]=outfive[i];
lx2[1]=outfive[i+1];
}
hPen=CreatePen(PS_SOLID3RGB(0+i*8i*20%255i*70));

Selectobject(hDChPen);
Polyline(hDClx22);
}


 for(i=0;i<5;i++)                     //画小五边形边线
{
if(i==4)
{
lx2[0]=infive[4];
    lx2[1]=infive[0];
}
else
{
lx2[0]=infive[i];
lx2[1]=infive[i+1];
}
hPen=CreatePen(PS_SOLID3RGB(255-i*8i*20%255i*70));


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5000  2008-11-09 19:44  五角星\55.cpp

     文件       3947  2008-11-06 10:43  五角星\5jiaoxing.dsp

     文件        543  2008-11-06 08:26  五角星\5jiaoxing.dsw

     文件      50176  2008-11-13 08:03  五角星\5jiaoxing.ncb

     文件      53760  2008-11-13 08:03  五角星\5jiaoxing.opt

     文件       1473  2008-11-09 19:44  五角星\5jiaoxing.plg

     文件      24571  2008-11-09 19:44  五角星\Debug\55.obj

     文件     184377  2008-11-09 19:44  五角星\Debug\5jiaoxing.exe

     文件     227744  2008-11-09 19:44  五角星\Debug\5jiaoxing.ilk

     文件    3557448  2008-11-09 19:42  五角星\Debug\5jiaoxing.pch

     文件     459776  2008-11-09 19:44  五角星\Debug\5jiaoxing.pdb

     文件     140288  2008-11-13 08:03  五角星\Debug\vc60.idb

     文件      77824  2008-11-09 19:44  五角星\Debug\vc60.pdb

     目录          0  2008-11-18 00:50  五角星\Debug

     目录          0  2008-11-18 00:50  五角星

----------- ---------  ---------- -----  ----

              4786927                    15


评论

共有 条评论