Extending System.Windows.Forms.Button class

M

Markus Eßmayr

Hello,

I'm writing an extension class for the winforms button control using MC++.
I created a class, derived from System::Windows::Forms::Button.
In my class I want to extend the functionality of the Image-property, so I
added the followind functions:

public __gc class ExtendedButton : public System::Windows::Forms::Button
{
public:
__property System::Drawing::Image* get_Image();
__property void set_Image(System::Drawing::Image* value);
};

System::Drawing::Image* ExtendedButton::get_Image()
{
return System::Windows::Forms::Button::get_Image();
}

void ExtendedButton::set_Image(System::Drawing::Image* value)
{
System::Windows::Forms::Button::set_Image(value);
}

My problem is, that VS2003 runs into an endless loop when I add that control
in a form.
It then consumes very much CPU and memory, and it doesn't stop itself.

What did I do wrong?
There must be a way!

Thanks in advance!
Max
 
M

Markus Eßmayr

Hello,

as I didn't get answer to this question, and it's very important for me, I
tried some other way to to that.
My current approach overrides the OnPaint method and performs some stuff
that should be ok for me.

The problem is, that my OnPain method isn't called.

Heres some source code:
public __gc class EnhancedButton : public System::Windows::Forms::Button
{
public:
// ... some methods
protected:
void OnPaint(System::Windows::Forms::paintEventArgs* pevent);
private:
// ... some methods and member variables
};

void EnhancedButton::OnPaint(System::Windows::Forms::paintEventArgs* pevent)
{
// ... do some stuff

// ... call OnPaint of the base class
System::Windows::Forms::Button::OnPaint(pevent);
return;
}

Has anybody an idea?

Thanks in advance!
Max

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top