We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

C++ Translation Problems (from Knowledge Base Q10533)

Thread ID:





22873 Dec 28,2004 04:55 AM UTC Dec 28,2004 08:02 PM UTC WinForms 2
Tags: GridControl
Dean Wittmann
Asked On December 28, 2004 04:55 AM UTC

I''ve tried attaching a zip file, but it doesn''t seem to work for me, so the code for the translated classes is at the end of this message. After translating the 3 classes from the ImagePushButton.cs file into C++ classes, I get the following error: error C2512: ''_12390::GridPushButtonImageCellRenderer'' : no appropriate default constructor available which MSDN describes as: No default constructor is available for the specified class, structure, or union. The compiler supplies a default constructor if user-defined constructors are not provided. If you provide a constructor that takes a nonvoid parameter, you must also provide a default constructor. The default constructor can be a constructor with default values for all parameters. The following sample generates C2512: // C2512.cpp class B { public: B (char *); /* add the folling constructor B() { }; */ }; int main() { B b; // C2512 } -------------- I have tried to supply a default constructor with no luck on trying to get rid of this error. Can anyone see the error of my ways? -------------- // Contents of ImagePushButton.h #pragma once using namespace System; using namespace System::Collections; using namespace System::Diagnostics; using namespace System::Drawing; using namespace System::Runtime::Serialization; using namespace System::Windows::Forms; using namespace System::IO; using namespace System::Drawing::Imaging; using namespace Syncfusion::Diagnostics; using namespace Syncfusion::Windows::Forms::Grid; namespace _12390 { public __gc class GridPushButtonImageCellRenderer; public __gc class GridPushButtonImageCellModel : public GridPushButtonCellModel { protected: GridPushButtonImageCellModel(SerializationInfo* pInfo, StreamingContext context) : GridPushButtonCellModel(pInfo, context) { } public: GridPushButtonImageCellModel(GridModel* pGrid) : GridPushButtonCellModel(pGrid) { } public: virtual GridCellRendererBase* CreateRenderer(GridControlBase* pControl) { return new GridPushButtonImageCellRenderer(pControl, this); } }; public __gc class ImageCellButton : public GridCellButton { private: static GridIconPaint* pIconPainter; private: static ImageCellButton() { pIconPainter = new GridIconPaint("_12390", GetExecutingAssembly()); } public: ImageCellButton(GridPushButtonCellRenderer* pControl) : GridCellButton(pControl) { } public: virtual void Draw(Graphics* pG, int iRowIndex, int iColIndex, bool bActive, GridStyleInfo* pStyle) { GridCellButton::Draw(pG, iRowIndex, iColIndex, bActive, pStyle); // draw the button bool bHovering = IsHovering(iRowIndex, iColIndex); bool bMouseDown = IsMouseDown(iRowIndex, iColIndex); bool bDisabled = !pStyle->Clickable; ButtonState buttonState = ButtonState::Normal; if (bDisabled) { buttonState |= ButtonState::Inactive | ButtonState::Flat; } else if (!bHovering && !bMouseDown) { buttonState |= ButtonState::Flat; } Point PtOffset = Point::Empty; if (bMouseDown) { PtOffset.X = 1; PtOffset.Y = 1; buttonState |= ButtonState::Pushed; } DrawButton(pG, Bounds, buttonState, pStyle); String bitmapName = S"Browse.bmp"; // make sure this is included in project and marked as "Embedded Resource" // Instead of using GridIconPaint you could simple use Image.Draw here // with an existing bitmap. GridIconPaint is convenient because it lets // us easily draw over existing background and replace the black color // in the bitmap with a different color. pIconPainter->PaintIcon(pG, Bounds, PtOffset, bitmapName, Color::Blue); } }; public __gc class GridPushButtonImageCellRenderer : public GridPushButtonCellRenderer { private: ImageCellButton* pPushButton; public: GridPushButtonImageCellRenderer(GridControlBase* pGrid, GridPushButtonImageCellModel* pCellModel) : GridPushButtonCellRenderer(pGrid, pCellModel) { GridPushButtonCellRenderer::RemoveButton(GridPushButtonCellRenderer::GetButton(0)); AddButton(pPushButton = new ImageCellButton(this)); } }; } ------------------------------ // Contents of ImagePushButton.cpp #include "ImagePushButton.h"

Dean Wittmann
Replied On December 28, 2004 04:59 AM UTC

I forgot to mention that the error line is in the function: --------------- public: virtual GridCellRendererBase* CreateRenderer(GridControlBase* pControl) { return new GridPushButtonImageCellRenderer(pControl, this); } --------------- The "return new GridPushButtonImageCellRenderer(pControl, this);" line to be exact. Thanks to anyone that can help me!!!

Dean Wittmann
Replied On December 28, 2004 08:02 PM UTC

Never Mind. I got it to compile correctly. Now, I''m just having problems loading the bitmap. I''m sure I''ll figure this one out too.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon