Archived

This topic is now archived and is closed to further replies.

Zipster

help me with this, plz

Recommended Posts

Heres the deal. I''m working on a paont program, and as of now i have a pencil mode and an ellipse mode for drawing. heres the code that draws the ellipse: int Draw_Circle_GDI(RECT *rect, int color, LPDIRECTDRAWSURFACE7 lpdds) { if(FAILED(lpdds->GetDC(&gv.xdc))) return(0); gv.p.x = 1; gv.lb.lbStyle = BS_SOLID; gv.lb.lbColor = RGB(palette[color].peRed, palette[color].peGreen, palette[color].peBlue); gv.lp.lopnStyle = PS_SOLID; gv.lp.lopnWidth = gv.p; gv.lp.lopnColor = RGB(palette[color].peRed, palette[color].peGreen, palette[color].peBlue); gv.pen = CreatePenIndirect(&gv.lp); gv.brush = CreateSolidBrush(RGB(palette[color].peRed, palette[color].peGreen, palette[color].peBlue)); gv.old_p = SelectObject(gv.xdc, gv.pen); gv.old_b = SelectObject(gv.xdc, gv.brush); Ellipse(gv.xdc, rect->left, rect->top, rect->right, rect->bottom); SelectObject(gv.xdc, gv.old_p); SelectObject(gv.xdc, gv.old_b); DeleteObject(gv.pen); DeleteObject(gv.brush); lpdds->ReleaseDC(gv.xdc); return(1); } ///////////////////////////// To make a long story short, whenver i run my painr program and only draw using the pencil tool (i.e not executing the above code), everything works fine. However once i run the program and draw ellipses (i.e executing the above code), everything works fine until i exit the program, where after i quit i get a "This function has performed an illegal operation...Access Violation.." error message (and it eats up resources like a bitch!). Why is the above code causing this error? (BTW, gv.xdc is a HDC gv.pen is a HPEN gv.old_p is a *HPEN gv.brush is HBRUSH...etv.)

Share this post


Link to post
Share on other sites