#include <iostream>
#include <graphics.h>
#include <atltypes.h>
using namespace std;
void CTestView::GetMaxX()//获得屏幕宽度
{
CRect Rect;
GetClientRect(&Rect);
MaxX = Rect.right;
}
void CTestView::GetMaxY()//获得屏幕高度
{
CRect Rect;
GetClientRect(&Rect);
MaxY = Rect.bottom;
}
void CTestView::ReadPoint()//读入点表函数
{
//设置第一个正方形的4个顶点
int a = 160;
P1[0] = CP2(MaxX / 4 - a, MaxY / 2 + a);//P0
P1[1] = CP2(MaxX / 4 + a, MaxY / 2 + a);//P1
P1[2] = CP2(MaxX / 4 + a, MaxY / 2 - a);//P2
P1[3] = CP2(MaxX / 4 - a, MaxY / 2 - a);//P3
//设置第二个正方形的4个顶点
int b = round(sqrt(2) * a);
P2[0] = CP2(3 * MaxX / 4, MaxY / 2 + b);//P0
P2[1] = CP2(3 * MaxX / 4 + b, MaxY / 2);//P1
P2[2] = CP2(3 * MaxX / 4, MaxY / 2 - b);//P2
P2[3] = CP2(3 * MaxX / 4 - b, MaxY / 2);//P3
}
void CTestView::DrawSquare(CDC* pDC, CP2* P)//绘制正方形函数
{
CP2 T;
CLine line;
for (int i = 0; i < 4; i++)//边循环
{
if (i == 0)
{
line.MoveTo(pDC, P[i]);
T = P[0];
}
else
{
line.LineTo(pDC, P[i]);;
}
}
line.LineTo(pDC, T);//闭合
}
void CTestView::OnMENUIFill()
{
// TODO: Add your command handler code here
COLORREF FColor;
CColorDialog ccd(RGB(255, 0, 0));
if (ccd.DoModal() == IDOK)//调用调色板选取色
{
FColor = ccd.GetColor();
m_Red = GetRValue(FColor);//获得颜色的红色分量
m_Green = GetGValue(FColor);//获得颜色的绿色分量
m_Blue = GetBValue(FColor);//获得颜色的蓝色分量
}
RedrawWindow();//刷新屏幕
FillRect(P1);//填充正方形1
FillRect(P2);//填充正方形2
}
void CTestView::FillRect(CP2* P)//填充正方形函数
{
CFill fill;
CPi2 Point[4];
for (int i = 0; i < 4; i++)
{
Point[i].x = P[i].x;
Point[i].y = ROUND(P[i].y);
Point[i].c = CRGB(double(m_Red) / 255.0, double(m_Green) / 255.0, double(m_Blue) / 255.0);
}
CDC* pDC = GetDC();
fill.SetPoint(Point, 4);//填充正方形
fill.CreateBucket();
fill.CreateEdge();
fill.Gouraud(pDC);
ReleaseDC(pDC);
}
严重性 代码 说明 项目 文件 行 禁止显示状态
错误(活动) E0020 未定义标识符 "P2" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 27
错误(活动) E0020 未定义标识符 "pDC" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 32
错误(活动) E0020 未定义标识符 "P1" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 21
错误(活动) E0020 未定义标识符 "P" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 32
错误(活动) E0020 未定义标识符 "MaxY" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 15
错误(活动) E0020 未定义标识符 "MaxY" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 21
错误(活动) E0020 未定义标识符 "MaxX" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 9
错误(活动) E0020 未定义标识符 "MaxX" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 21
错误(活动) E0020 未定义标识符 "CP2" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 21
错误(活动) E0020 未定义标识符 "CP2" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 32
错误(活动) E0020 未定义标识符 "CDC" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 32
错误 C1083 无法打开包括文件: “graphics.h”: No such file or directory ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 3
错误(活动) E1696 无法打开 源 文件 "graphics.h" ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 2
错误(活动) E0169 应输入声明 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 49
错误(活动) E0065 应输入“;” ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 33
错误(活动) E0276 后面有“::”的名称一定是类名或命名空间名 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 5
错误(活动) E0276 后面有“::”的名称一定是类名或命名空间名 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 11
错误(活动) E0276 后面有“::”的名称一定是类名或命名空间名 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 17
错误(活动) E0276 后面有“::”的名称一定是类名或命名空间名 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 32
错误(活动) E0165 函数调用中的参数太少 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 8
错误(活动) E0165 函数调用中的参数太少 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 14
错误(活动) E0167 "CRect *" 类型的实参与 "HWND" 类型的形参不兼容 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 8
错误(活动) E0167 "CRect *" 类型的实参与 "HWND" 类型的形参不兼容 ConsoleApplication4 D:\Microsoft Visual Studio\ConsoleApplication4\ConsoleApplication4\源.cpp 14