Справочник функций

Ваш аккаунт

Войти через: 
Забыли пароль?
Регистрация
Информацию о новых материалах можно получать и без регистрации:

Почтовая рассылка

Подписчиков: -1
Последний выпуск: 19.06.2015

Векторный графический редактор___ошибка в классе___помогите плиз))))

55K
23 декабря 2009 года
lk-5674
1 / / 23.12.2009
Не получается исправить ошибку. Когда пытаюсь сохранить несколько линий выдает ошибку.....
typedef struct{ //class
public:
POINT P;
COLORREF iColorPen;
COLORREF iColorBrush;
int iPenWidth;
int FigureType;
int Rezhim;
}MYPOINT;
MYPOINT mp;
MYPOINT FunctionMyPoint(POINT P, COLORREF iColorPen, COLORREF iColorBrush, int FCheck,int iPenWidth,int Rezhim){
mp.P = P;
mp.iPenWidth = iPenWidth;
mp.iColorPen = iColorPen;
mp.iColorBrush = iColorBrush;
mp.FigureType = FCheck;
mp.Rezhim = Rezhim;
return mp;
}
class MyLine{
public:
MYPOINT *MyPoints;
int len;

MyLine();
~MyLine();
void Add(MYPOINT);
//void DrawLine(HWND, HDC);
};
MyLine::MyLine(){
MyPoints = new MYPOINT();
len = 0;
}
MyLine::~MyLine(){
if (MyPoints != NULL) {
delete [] MyPoints;
MyPoints = NULL;
}
}
void MyLine::Add(MYPOINT MyPointsAdd){
MYPOINT *new_MyPoints = new MYPOINT[len+1];
for (int i = 0; i < len; i++)
new_MyPoints = MyPoints;

if ((MyPoints != NULL)&&(len > 0)) {
delete [] MyPoints;
MyPoints = NULL;
}
MyPoints = new_MyPoints;

MyPoints[len++] = MyPointsAdd;
}
/*
void MyLine::DrawLine(HWND hWnd, HDC hdc){
InvalidateRect(hWnd, NULL, FALSE);
PAINTSTRUCT ps;
HPEN hPen;
HBRUSH hBrush;
hdc = BeginPaint(hWnd, & ps);
for (int i = 0; i<len-1; i++){
hPen = CreatePen(SPen, iPenWidth, iColorPen);
SelectObject(hdc, hPen);
hBrush = CreateSolidBrush(iColorBrush);
SelectObject(hdc, GetStockObject(NULL_BRUSH));
hPen = CreatePen(PS_SOLID, iPenWidth, iColorPen);
SelectObject(hdc, hPen);
if (FCheck == 0){
MoveToEx(hdc, MyPoints.P.x, MyPoints.P.y, NULL);
LineTo(hdc, MyPoints[i+1].P.x, MyPoints[i+1].P.y);
}
}
if(len!=0){
DeleteObject(hPen);
DeleteObject(hBrush);
EndPaint(hWnd, & ps);
}
}*/
class LINES{ //class
public:
MyLine *Line; //Line = new MyLine();
int len;
LINES();
~LINES();
void Add(MyLine);
void DrawLines(HWND, HDC);
};
LINES::LINES(){
Line = new MyLine();
len = 0;
}
LINES::~LINES(){
if ((Line != NULL)&&(len > 0)) {
delete [] Line;
Line = NULL;
}
}
void LINES::Add(MyLine LineN){
MyLine *new_Line = new MyLine[len+1];
for (int i = 0; i < len; i++)
new_Line = Line;

if ((Line != NULL)&&(len > 0)) {
delete [] Line;
Line = NULL;
}
Line = new_Line;

Line[len++] = LineN;
}
void LINES::DrawLines(HWND hWnd, HDC hdc){
InvalidateRect(hWnd, NULL, FALSE);
PAINTSTRUCT ps;
HPEN hPen;
HBRUSH hBrush;
hdc = BeginPaint(hWnd, & ps);
for (int j=0; j<len; j++){
for (int i = 0; i<Line.len-1; i++){
hPen = CreatePen(SPen, Line[j].MyPoints.iPenWidth, Line[j].MyPoints.iColorPen);
SelectObject(hdc, hPen);
hBrush = CreateSolidBrush(Line[j].MyPoints.iColorBrush);
SelectObject(hdc, GetStockObject(NULL_BRUSH));
hPen = CreatePen(PS_SOLID, Line[j].MyPoints.iPenWidth, Line[j].MyPoints.iColorPen);
SelectObject(hdc, hPen);
if (FCheck == 0){
MoveToEx(hdc,Line[j].MyPoints.P.x, Line[j].MyPoints.P.y, NULL);
LineTo(hdc, Line[j].MyPoints[i+1].P.x, Line[j].MyPoints[i+1].P.y);
}
}
}
if(len!=0){
DeleteObject(hPen);
DeleteObject(hBrush);
EndPaint(hWnd, & ps);
}
}
typedef struct{ //class
public:
POINT A1;
POINT B1;
// MyLine Line; //Line = new MyLine();
int len;
COLORREF iColorPen;
COLORREF iColorBrush;
int iPenWidth;
int FigureType;
int Rezhim;
//WriteFile
}MYFIGURE,*LPMYFIGURE; //LPCVOID;

typedef class Picture{ //class
public:
MYFIGURE *myFigure;
int len;
Picture();
~Picture();
void Add(MYFIGURE);
void DrawAll(HWND, HDC);
}MYPICTURE;

Picture::Picture(){
myFigure = new MYFIGURE();
len = 0;
}

Picture::~Picture(){
if (myFigure != NULL) {
delete [] myFigure;
myFigure = NULL;
}
}
void Picture::Add(MYFIGURE myFigureAdd){
MYFIGURE *new_Figure = new MYFIGURE[len+1];
for (int i = 0; i < len; i++)
new_Figure = myFigure;

if ((myFigure != NULL)&&(len > 0)) {
delete [] myFigure;
myFigure = NULL;
}
myFigure = new_Figure;

myFigure[len++] = myFigureAdd;
}
void Picture::DrawAll(HWND hWnd, HDC hdc){
InvalidateRect(hWnd, NULL, FALSE);
PAINTSTRUCT ps;
HPEN hPen;
HBRUSH hBrush;
hdc = BeginPaint(hWnd, & ps);
for(int i=0; i<len; i++){

hPen = CreatePen(SPen, myFigure.iPenWidth, myFigure.iColorPen);
SelectObject(hdc, hPen);
hBrush = CreateSolidBrush(myFigure.iColorBrush);
switch(myFigure.Rezhim)
{
case 0:
SelectObject(hdc, GetStockObject(NULL_BRUSH));
break;
case 1:
SelectObject(hdc, hBrush);
break;
case 2:
SelectObject(hdc, hBrush);
SelectObject(hdc, GetStockObject(NULL_PEN));
break;
}

switch(myFigure.FigureType)
{
//case 0:
// myFigure.Line.DrawLine(hWnd,hdc);
// break;
case 1:
MoveToEx(hdc, myFigure.A1.x, myFigure.A1.y, NULL);
LineTo(hdc, myFigure.B1.x, myFigure.B1.y);
break;
case 2:
Rectangle(hdc, myFigure.A1.x, myFigure.A1.y, myFigure.B1.x, myFigure.B1.y);
break;
case 3:
Ellipse(hdc, myFigure.A1.x, myFigure.A1.y, myFigure.B1.x, myFigure.B1.y);
break;
}
BitBlt(mdc, 0, 0, h, v, hdc, 0, 0, SRCCOPY);
}
if(len!=0){
DeleteObject(hPen);
DeleteObject(hBrush);
EndPaint(hWnd, & ps);
}
}

static MYFIGURE mf;
MYFIGURE FunctionMyFigure(POINT pointA,POINT pointB, COLORREF iColorPen, COLORREF iColorBrush, int FCheck,int iPenWidth,int Rezhim){
//mf.Line = Line; //MyLine *Line,
mf.A1 = pointA;
mf.B1 = pointB;
mf.iPenWidth = iPenWidth;
mf.iColorPen = iColorPen;
mf.iColorBrush = iColorBrush;
mf.FigureType = FCheck;
mf.Rezhim = Rezhim;
return mf;
}
Реклама на сайте | Обмен ссылками | Ссылки | Экспорт (RSS) | Контакты
Добавить статью | Добавить исходник | Добавить хостинг-провайдера | Добавить сайт в каталог