Jump to content
  • Advertisement

Archived

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

Zipster

help me with this, plz

This topic is 6781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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) { HDC xdc; HPEN pen; LOGPEN lp; POINT p; HBRUSH brush; LOGBRUSH lb; if(FAILED(lpdds->GetDC(&xdc))) return(0); SetBkMode(xdc, TRANSPARENT); p.x = 1; lb.lbStyle = BS_SOLID; lb.lbColor = RGB(palette[color].peRed, palette[color].peGreen, palette[color].peBlue); lp.lopnStyle = PS_SOLID; lp.lopnWidth = p; lp.lopnColor = RGB(palette[color].peRed, palette[color].peGreen, palette[color].peBlue); pen = CreatePenIndirect(&lp); brush = CreateSolidBrush(RGB(palette[color].peRed, palette[color].peGreen, palette[color].peBlue)); SelectObject(xdc, pen); SelectObject(xdc, brush); Ellipse(xdc, rect->left, rect->top, rect->right, rect->bottom); DeletePen(pen); DeleteBrush(brush); lpdds->ReleaseDC(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..." error message. Why is the above code causing this error?

Share this post


Link to post
Share on other sites
Advertisement
im glad to know no one can solve this one!!

makes me feel special!!

what i meant to say:
my god people!! is this really that hard!!! ;(

Edited by - Zipster on 3/31/00 1:10:18 AM

Share this post


Link to post
Share on other sites
You must restore the original objects in the DC before deleting them, otherwise you app will crash.

HPEN OldPen = SelectObject(xdc, pen);

... Draw Something

SelectObject(xdc, OldPen);
DeleteObject(pen);

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!