WinForms: How to override this method?
-
I'm trying to make simple class derived from ComboBox that processes some command keys. Here is the code:
#pragma once using namespace System; using namespace System::Windows::Forms; namespace ProjectX { public ref class EnterComboBox : public ComboBox { public: EnterComboBox(void) { } protected: virtual void ComboBox::ProcessCmdKey(Message^% msg, Keys^ k) override { MessageBox::Show("cmdkey"); ComboBox::ProcessCmdKey(&msg, k); } }; }
The compiler outputs error C3254: 'ProjectX::EnterComboBox' : class contains explicit override 'ProcessCmdKey' but does not derive from an interface that contains the function declaration I'm confused. There is no such interface. I've searched whole e-books, forums for the code sample (and more common overrides, like OnPaint, OnResize etc.) and there is no answer how the hell override some method from the Control's base class :mad: -
I'm trying to make simple class derived from ComboBox that processes some command keys. Here is the code:
#pragma once using namespace System; using namespace System::Windows::Forms; namespace ProjectX { public ref class EnterComboBox : public ComboBox { public: EnterComboBox(void) { } protected: virtual void ComboBox::ProcessCmdKey(Message^% msg, Keys^ k) override { MessageBox::Show("cmdkey"); ComboBox::ProcessCmdKey(&msg, k); } }; }
The compiler outputs error C3254: 'ProjectX::EnterComboBox' : class contains explicit override 'ProcessCmdKey' but does not derive from an interface that contains the function declaration I'm confused. There is no such interface. I've searched whole e-books, forums for the code sample (and more common overrides, like OnPaint, OnResize etc.) and there is no answer how the hell override some method from the Control's base class :mad:You have a mismatch, and it should be:
virtual bool ProcessCmdKey( Message% msg, Keys keyData ) override
"We make a living by what we get, we make a life by what we give." --Winston Churchill
-
You have a mismatch, and it should be:
virtual bool ProcessCmdKey( Message% msg, Keys keyData ) override
"We make a living by what we get, we make a life by what we give." --Winston Churchill
Now it works, thanks. But another few hours have been spoiled on this either.