[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
DeleteObject() in fatak error
From: "Franco Casadei" ####@####.#### Date: 30 Jan 2007 15:59:06 +0000 Message-Id: <002e01c74487$80561f70$0300a8c0@franco> Sometimes the funciton DeleteObject() crashes the system ; I get an "External Memory Address Error". This function works fine, but the it crash. static MyDrawRect(HDC hdc, int x , int y, int h, int w, int width, int color) { HPEN rectPen; POINT p[5]; p[0].x = x; p[0].y = y; p[1].x = x + w; p[1].y = y ; p[2].x = x + w; p[2].y = y + h ; p[3].x = x; p[3].y = y + h ; p[4].x = x; p[4].y = y; rectPen = CreatePen(1,1,color); SelectObject(hdc, rectPen); Polyline(hdc,p,5); if (width == 2){ /* rettangolo interno*/ p[0].x++; p[0].y++; p[1].x--; p[1].y++; p[2].x--; p[2].y--; p[3].x++; p[3].y--; p[4].x++; p[4].y++; Polyline(hdc,p,5); } /* This make the system crash */ DeleteObject(SelectObject(hdc, rectPen)); } What happans if I omit to call DeleteObject() ? Thanks, Casadei Franco | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] DeleteObject() in fatak error
From: "Uwe Klatt" ####@####.#### Date: 31 Jan 2007 06:48:29 +0000 Message-Id: <004601c74503$bd922b00$081710ac@arnstein.miwe.de> Hello Franco, > rectPen = CreatePen(1,1,color); > oldPen = SelectObject(hdc, rectPen); > ... > DeleteObject(SelectObject(hdc, oldPen)); You must restore old Pen! Bye Uwe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |