I am having trouble overriding the virtual functions from the parent class Label. Can anyone please help me on what the correct syntax for the declaration and implementation of OnMouseEnter, OnMouseDown, OnMouseLeave, OnMouseUp etc.

using namespace System;
using namespace System::Collections;
using namespace System::Linq;
using namespace System::Text;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace SliderControl{

	ref class SliderButton : public Label {

			void OnMouseEnter(EventArgs^);
			void OnMouseLeave(EventArgs^);
			void OnMouseDown(EventArgs^);
			void OnMouseUp(EventArgs^);
			void OnPaint(PaintEventArgs^);

			System::Drawing::Image^ backgroundImage;
			System::Drawing::Image^ pressedImage;
			bool pressed;
			bool _over;

			void CheckEnterOrLeave(int, int);
			bool IsPressed();
			System::Drawing::Image^ SetBackgroundImage(System::Drawing::Image^);
			System::Drawing::Image^ SetPressedImage(System::Drawing::Image^);

		pressed = false;
		_over = false;

    void SliderButton::CheckEnterOrLeave(int x, int y) 
        bool overControl = x >= this->Location.X &&
                           x <= this->Location.X + this->Width &&
                           y >= this->Location.Y &&
                           y <= this->Location.Y + this->Height;
        if (overControl && !_over)
            this->OnMouseEnter(gcnew EventArgs());
        else if(!overControl && _over)
            this->OnMouseLeave(gcnew EventArgs());

    // Property for the background image to be drawn behind the button text.
	Image^ SliderButton::SetBackgroundImage(System::Drawing::Image^ im){
        backgroundImage = im;

    // Property for the background image to be drawn behind the button text when
    // the button is pressed.
    Image^ SliderButton::SetPressedImage(System::Drawing::Image^ im){
        pressedImage = im;

    bool SliderButton::IsPressed()
        return pressed;

	override void SliderButton::OnMouseEnter(EventArgs^ e)
        _over = true;

    override void SliderButton::OnMouseLeave(EventArgs^ e)
        _over = false;

    // When the mouse button is pressed, set the "pressed" flag to true 
    // and invalidate the form to cause a repaint.  The .NET Compact Framework 
    // sets the mouse capture automatically.
    override void SliderButton::OnMouseDown(MouseEventArgs^ e)
        pressed = true;

    // When the mouse is released, reset the "pressed" flag 
    // and invalidate to redraw the button in the unpressed state.
    override void SliderButton::OnMouseUp(MouseEventArgs^ e)
        pressed = false;

    // Override the OnPaint method to draw the background image
    override void SliderButton::OnPaint(PaintEventArgs^ e)
        if (this.pressed && this.pressedImage != null)
            e.Graphics.DrawImage(this.pressedImage, 0, 0);
            e.Graphics.DrawImage(this.backgroundImage, 0, 0);


also, I am basically porting this code over from a C# class I had written, can anyone tell me if I am using the parent class correctly:


Thanks for your time and expertise.

Just like always, right after I had given up searching and posting and decided to reach out fro help, I found my solution. However, I still would like to be sure of the base class equivalence issue, because there weren't very many resources available. Thanks!

Be a part of the DaniWeb community

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