I am trying to declare a Doublebuffered panel in C++
I can only find the declaration for this in C#.

So I wonder how this could be converted to C++ ?

public class DoubleBufferPanel : Panel
{
    public DoubleBufferPanel()
    {
        // Set the value of the double-buffering style bits to true.



        this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint |
                      ControlStyles.AllPaintingInWmPaint, true);

        this.UpdateStyles();
    }
}

This should do ..

public ref class DoubleBufferPanel : public Panel
  {
  public:
    DoubleBufferPanel(void)
    {
        this->SetStyle(ControlStyles::DoubleBuffer
         | ControlStyles::UserPaint
         | ControlStyles::AllPaintingInWmPaint,
          true);

        this->SetStyle(ControlStyles::DoubleBuffer, true);
        this->UpdateStyles();
    }
  };

I am very happy for this conversion as I am really trying to get this work. It almosts compiles. I get one compileerror though.

I have put the declaration excactly as you showed but get this compileerror.
I am not sure what could be missing ?

Compileerror:
error C3379: 'Form1::Form2:: DoubleBufferPanel' : a nested class cannot have an assembly access specifier as part of its declaration

This should do ..

public ref class DoubleBufferPanel : public Panel
  {
  public:
    DoubleBufferPanel(void)
    {
        this->SetStyle(ControlStyles::DoubleBuffer
         | ControlStyles::UserPaint
         | ControlStyles::AllPaintingInWmPaint,
          true);

        this->SetStyle(ControlStyles::DoubleBuffer, true);
        this->UpdateStyles();
    }
  };

error C3379: 'Form1::Form2:: DoubleBufferPanel' : a nested class cannot have an assembly access specifier as part of its declaration

Move the DoubleBufferPanel class outside your Form class i.e.

#pragma once

namespace Form1 { // <- You might have another namespace here
 // the usual 'using ...' stuff follows
 using namespace System;
 // etc ...
 // Next your new class ...
 public ref class DoubleBufferPanel : public Panel
  {
  public:
    DoubleBufferPanel(void)
    {
        this->SetStyle(ControlStyles::DoubleBuffer
         | ControlStyles::UserPaint
         | ControlStyles::AllPaintingInWmPaint,
          true);

        this->SetStyle(ControlStyles::DoubleBuffer, true);
        this->UpdateStyles();
    }
  };
 // Followed by the original code ...
 public ref class Form1 : public System::Windows::Forms::Form
 ...

Thank you very much for the help... that did compile fine.

I will continue working with this now and see if I can make any progress using this panel.

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.