I am doing some GDI+ drawing in Visual C++ and noticed that my canvas doesn't look the best when scrolling, resizing, etc... due to lots of flickering and slow redraws. From what I've read, the solution is to double buffer but there are conflicting suggestions on how to implement.
A few sources suggest to use the existing .NET implementation, like so:
using namespace System::Windows::Forms;
this->SetStyle(ControlStyles::AllPaintingInWmPaint |
ControlStyles::UserPaint |
ControlStyles::DoubleBuffer, true);
Many more sources recommend just drawing to your own bitmap and then throwing it onto the screen:
dbBitmap = gcnew Bitman(ClientRectangle.Width, ClientRectangle.Height);
dbGraphics = Graphics::FromImage(dbBitmap);
// use the graphics object to do everything you need to here
this->createGraphics()->DrawImageUnscaled(dbBitmap, 0, 0);
Is there a functional difference between these approaches, or would I just be bringing to the forefront what Microsoft does in the background? I'm concerned about both speed and efficiency, as well as possible pitfalls of using one approach over the other.