943,102 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 646
  • C++ RSS
Feb 5th, 2010
0

Convert this C# declaration to C++

Expand Post »
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++ ?
C++ Syntax (Toggle Plain Text)
  1. public class DoubleBufferPanel : Panel
  2. {
  3. public DoubleBufferPanel()
  4. {
  5. // Set the value of the double-buffering style bits to true.
  6.  
  7.  
  8.  
  9. this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint |
  10. ControlStyles.AllPaintingInWmPaint, true);
  11.  
  12. this.UpdateStyles();
  13. }
  14. }
Similar Threads
Reputation Points: 10
Solved Threads: 1
Posting Whiz in Training
Lukezzz is offline Offline
268 posts
since Mar 2008
Feb 5th, 2010
0
Re: Convert this C# declaration to C++
This should do ..
C++ Syntax (Toggle Plain Text)
  1. public ref class DoubleBufferPanel : public Panel
  2. {
  3. public:
  4. DoubleBufferPanel(void)
  5. {
  6. this->SetStyle(ControlStyles::DoubleBuffer
  7. | ControlStyles::UserPaint
  8. | ControlStyles::AllPaintingInWmPaint,
  9. true);
  10.  
  11. this->SetStyle(ControlStyles::DoubleBuffer, true);
  12. this->UpdateStyles();
  13. }
  14. };
Reputation Points: 1105
Solved Threads: 389
Posting Virtuoso
mitrmkar is offline Offline
1,713 posts
since Nov 2007
Feb 5th, 2010
0
Re: Convert this C# declaration to C++
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

Click to Expand / Collapse  Quote originally posted by mitrmkar ...
This should do ..
C++ Syntax (Toggle Plain Text)
  1. public ref class DoubleBufferPanel : public Panel
  2. {
  3. public:
  4. DoubleBufferPanel(void)
  5. {
  6. this->SetStyle(ControlStyles::DoubleBuffer
  7. | ControlStyles::UserPaint
  8. | ControlStyles::AllPaintingInWmPaint,
  9. true);
  10.  
  11. this->SetStyle(ControlStyles::DoubleBuffer, true);
  12. this->UpdateStyles();
  13. }
  14. };
Last edited by Lukezzz; Feb 5th, 2010 at 9:50 pm.
Reputation Points: 10
Solved Threads: 1
Posting Whiz in Training
Lukezzz is offline Offline
268 posts
since Mar 2008
Feb 5th, 2010
0
Re: Convert this C# declaration to C++
Click to Expand / Collapse  Quote originally posted by Lukezzz ...
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.

C++ Syntax (Toggle Plain Text)
  1. #pragma once
  2.  
  3. namespace Form1 { // <- You might have another namespace here
  4. // the usual 'using ...' stuff follows
  5. using namespace System;
  6. // etc ...
  7. // Next your new class ...
  8. public ref class DoubleBufferPanel : public Panel
  9. {
  10. public:
  11. DoubleBufferPanel(void)
  12. {
  13. this->SetStyle(ControlStyles::DoubleBuffer
  14. | ControlStyles::UserPaint
  15. | ControlStyles::AllPaintingInWmPaint,
  16. true);
  17.  
  18. this->SetStyle(ControlStyles::DoubleBuffer, true);
  19. this->UpdateStyles();
  20. }
  21. };
  22. // Followed by the original code ...
  23. public ref class Form1 : public System::Windows::Forms::Form
  24. ...
Reputation Points: 1105
Solved Threads: 389
Posting Virtuoso
mitrmkar is offline Offline
1,713 posts
since Nov 2007
Feb 5th, 2010
0
Re: Convert this C# declaration to C++
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!
Reputation Points: 10
Solved Threads: 1
Posting Whiz in Training
Lukezzz is offline Offline
268 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: How to Create an Expression Evaluator in C++
Next Thread in C++ Forum Timeline: Tic-Tac-Toe





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC