C++ Question

Customizing MenuStrip in Visual C++

This is the first time I am asking a question, so please pardon me if I break a few rules.

I need to customize a MenuStrip with visual C++. I have tried creating a ColorTable but it has been telling me that I cannot override a non-virtual method of a class, at other attempts it tells me I cannot override properties.

I am currently unable to post some of my attempts as I own a Mac while I use a windows system in the office.

Please any guide will be appreciated.

Answer Source

I finally figured it out myself.

Fist, create a custom ColorTable. For example:

public ref class MyCustomColorTable: public  ProfessionalColorTable
{
public:
    property Color MenuBorder {
        public: virtual Color get() override {
            return Color::FromArgb(180, 180, 185);
        };
    };
    property Color MenuItemBorder {
        public: virtual Color get() override {
            return Color::FromArgb(0, 0, 0, 0);
        };
    };
    property Color ImageMarginGradientBegin {
        public: virtual Color get() override {
            return Color::FromArgb(0, 0, 0, 0);
        };
    };
    property Color ImageMarginGradientMiddle {
        public: virtual Color get() override {
            return Color::FromArgb(0, 0, 0, 0);
        };
    };
    property Color ImageMarginGradientEnd {
        public: virtual Color get() override {
            return Color::FromArgb(0, 0, 0, 0);
        };
    };
    property Color ToolStripDropDownBackground {
        public: virtual Color get() override {
            return Color::FromArgb(248, 248, 248);
        };
    };
};

Secondly, Then in your forms onLoad event, do something like this:

this->menuStrip->Renderer = gcnew ToolStripProfessionalRenderer(gcnew MyCustomColorTable());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download