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();
    }
  };

Edited 6 Years Ago by Lukezzz: n/a

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!

This question has already been answered. Start a new discussion instead.