Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1011593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:15:27+00:00 2026-05-16T09:15:27+00:00

Ok so my double buffer works fine but it seems that it use a

  • 0

Ok so my double buffer works fine but it seems that it use a lot of memory.

i know that double buffer should store a copy of the ellipse I’m drawing than paint it on the screen but it after that it deletes the copy and makes new copy but it doesn’t seem to delete it
here is my code

hdc=GetDC(hWnd);
HDC memDC=CreateCompatibleDC(hdc);
HBITMAP hMemMap=CreateCompatibleBitmap(hdc, 300, 300);
HBITMAP hOldMap=(HBITMAP)SelectObject(memDC, hMemMap);

// Drawing
Graphics draw(memDC);
draw.FillRectangle(&green, 0, 0, 300, 25);
Font font(&fontfamily, 14, 0, UnitPixel);
PointF p1(180.0f, 4.0f);
PointF p2(30.0f, 4.0f);
draw.DrawString(level, -1, &font, p2, &blue);
draw.DrawString(str, -1, &font, p1, &blue);
draw.FillEllipse(&red, ball1.Ex, ball1.Ey, 25, 25);
draw.FillEllipse(&red, ball2.Ex, ball2.Ey, 25, 25);
draw.FillEllipse(&red, ball3.Ex, ball3.Ey, 25, 25);
draw.FillEllipse(&red, ball4.Ex, ball4.Ey, 25, 25);
draw.FillEllipse(&red, ball5.Ex, ball5.Ey, 25, 25);
draw.FillEllipse(&red, ball6.Ex, ball6.Ey, 25, 25);
draw.FillEllipse(&red, ball7.Ex, ball7.Ey, 25, 25);
draw.FillEllipse(&red, ball8.Ex, ball8.Ey, 25, 25);
draw.FillEllipse(&red, ball9.Ex, ball9.Ey, 25, 25);
draw.FillEllipse(&red, ball10.Ex, ball10.Ey, 25, 25);
BitBlt(hdc, 0, 0, 300, 300, memDC, 0, 0, SRCCOPY);
SelectObject(memDC, hOldMap);
DeleteObject(hMemMap);
DeleteDC(memDC);

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:15:28+00:00Added an answer on May 16, 2026 at 9:15 am

    You are destroying all objects, but not the DC. You must call ReleaseDC after the drawing.

    See the MSDN:

    After painting with a common device context, the ReleaseDC function must be called to release the device context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to double buffer a custom control which contains buttons. I have tried
When you double click on a class (in 'solution explorer')... if that class happens
If you return a double or float from your MBean jconsole seems to round
I have double (or float) variables that might be empty, as in holding no
I learned that memset(ptr, 0, nbytes) is really fast, but is there a faster
I know its probably possible, but is it practical and doable to try and
I know its probably possible, but is it practical and doable to try and
I tried to just use the 'w' tag while opening the file, but it
I noticed that they don't return pointers when created, but actual objects. So to
Hello I am making a double buffer in C# and I need to find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.