473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

c++ gdi+ double buffer problem

14
ok i have no idea how double buffer works
i really need good sample example or tutorial
thanks
Ramiz
Aug 10 '10 #1
3 5169
Joseph Martell
198 Expert 128KB
Gdi+ doesn't have a "double buffer" setting so you have to do it manually (as far as I know).

Basically, you create an image (Gdiplus::Bitmap) the size of the window's client area (or whatever size you want) to act as your buffer. Then create a Gdiplus::Graphics object using the buffer image as a parameter for the constructor. Draw everything using the buffer Graphics object. After all of your drawing is done you draw your buffer image to the window's active graphics object.
Aug 10 '10 #2
ramilol
14
can you give me an simple example with code
Aug 10 '10 #3
Joseph Martell
198 Expert 128KB
here is a snippet of code that I used in a program I wrote a while ago:

Expand|Select|Wrap|Line Numbers
  1. //get the rectangle of the active window
  2. RECT clientRec;
  3. GetClientRect(_platformInfo->hWindow, &clientRec);
  4.  
  5. //create the buffer image
  6. _buffer = new Gdiplus::Bitmap(clientRec.right - clientRec.left, clientRec.bottom - clientRec.top, _currentGraphics);
  7.  
  8. //create the graphics object to draw on the buffer
  9. Gdiplus::Graphics *bufferGraphics = Gdiplus::Graphics::FromImage(_buffer);
  10.  
  11. /*Draw a bunch of stuff*/
  12. _currentGraphics->DrawImage(_buffer, 0, 0);
  13.  
  14.  
Obviously, this isn't complete code, but the basic idea is still there. I create a new image to act as the buffer (line 6). Using that particular constructor creates a bitmap that is compatible with the "real" graphics object and is the size of the entire client area of the window. In order to draw on a bitmap with GDI+ you need a Graphics object for that particular bitmap (line 9). Then draw as usual with the buffer Graphics object. The final step is to draw the buffer image with the real graphics object.

Well, I suppose the final step would be to clean up my _buffer and bufferGraphics objects.

There may be other, better, ways to do this, but this was all that I could find when I was searching. Hope it helps.
Aug 11 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: gaool | last post by:
Hello, I wrote a python script (python 2.3.3) to send some commands to a programm and to show on the screen the responses of this programm. I use "Pipedream.py" module in my script to speak with...
3
by: Ice Man | last post by:
Hi I want to send e-mails using an asp page first I create the mail Object: Set objMail = Server.CreateObject("CDONTS.NewMail") After I fill a variable with the html code that will be the...
0
by: Harry_Crow | last post by:
I'm painting in the Non Client area of the control. I'm facing some flicker problem. Is it possible to achive Double buffer painting in Non Client area. The SetStyle with...
3
by: MichaelTPaul | last post by:
Is anyone aware of the GDI+ region union problem especially in C# Link to site below http://www.opac.ch/bugs Thanks Michael Paul
2
by: Darryl A. J. Staflund | last post by:
Hi there, Can anyone tell me why invoking a single SQL insert statement (well, rather, a method that performs a SQL insert) using an asynchronous delegate should result in twice the number of...
1
by: Kuba Florczyk | last post by:
Hi I've got some problem doing double buffer. Here is my problem: I've got custom control on which i paint some data (chat messages, lets call it ChatControl), this control is puted on a...
7
by: Rain | last post by:
Hello Gurus! I really need this one to finish a module in my thesis. PLease please help me. I need a double buffer class so i can call it and use it anytime i want, the problem is everything ive...
1
by: Rain | last post by:
Hello Gurus! I really need this one to finish a module in my thesis. PLease please help me. I need a double buffer class in C# so i can call it and use it anytime i want, the problem is...
1
by: GregG | last post by:
This is information for those who may have been bitten by the "double-post" problem in GridView controls. I've been messing with ASP.Net about a week, and have uncovered an annoying 'feature'....
15
by: ABC | last post by:
Hi, I have a problem with Double submission in html forms. I am using PHP as the server side scripting language, i have found a means to capture the second form submission while the first form...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.