With The Case Of  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
ActiveX COM Products
Technical Support
  General Q & A
Discussion Board
Contact Us


Get Ready to Unleash the Power of UCanCode .NET

UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"

VC++ Example and Article: Drawing Double Buffering With GDI+

Simple example about Double Buffering with GDI+


Sample Image - GDIPlus.jpg


This is a simple example about GDI+ which I used in my first GDI+ project.This article is focused on Double Buffering. First if you want to add GDI+ supports to your project,you can refer to Starting with GDI+.
The main part of my example is in
OnPaint function that you can see everything there,Image,Font,Brush and etc.They are very clear so I don't discuss about them.I only explain "Double Buffering" here.

As you know you can draw images into your windows and create a brush or pen from TextureBrush and draw shapes or line, using the image.Even you can draw a text using the images by supplying TextureBrush.(you can see the examples in this article or articles)

I think one of the most important use of images is Double Buffernig technique.This technique is used when the drawing we wish to create has many details,and it is time consuming to draw even with a fast computer.In this situation it seems the image creeps on to the screen while being drawn.For example in mapping applications or CAD/CAM applications we would encounter this problem. In this technique instead of drawing in the screen,first we draw into an image and then we draw the iamge into the window. Here is my example in double buffering:

Collapse Copy Code
   srand( (unsigned)time( NULL ) );
   int number = rand();
   number /= RAND_MAX + 1; 
   number *= 254;

   Rect rc(rect.left,,rect.right,rect.bottom);
      Bitmap bmp(rect.right,rect.bottom);

   // Create a Graphics object that is associated with the image.
   Graphics* graph = Graphics::FromImage(&bmp);
   for(int x=0;x<rect.right;x++)
   	for(int y=0; y<rect.bottom; y++)
   		double number = rand();
  		number /= RAND_MAX + 1; 
		number *= 254;
		Pen pen(Color(number,number,number,number));
   // Draw the altered image.

It takes 36 seconds to paint the screen on my computer(AMD 1.33GHtz and 256Mb RAM) without double buffering but only 5 seconds with this technique.You know,it is not interesting to wait 36 seconds each time that your window need to repaint!



Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to