Hi T,
>> Hi,
>>
[quoted text clipped - 9 lines]
> to redeclare the event as:
> __event KeyEventHandler *KeyDown;
As far as I know managed classes inherit public by default in contrast to
native C++. So did you explicitly inherit private from Panel? Alternatively
you could try to explicitly inherit with "public Panel"
Otherwise this could indicate a compiler bug.
--
SvenC
T - 14 May 2007 18:24 GMT
Hi SvenC,
Here is the code:
[code]
namespace NuDesign {
using namespace System::Windows::Forms;
public __gc class ndPanel : public System::Windows::Forms::Panel {
public:
__event KeyEventHandler *KeyDown;
virtual bool ProcessCmdKey(Message __gc *msg, Keys key){
if(msg->Msg == 0x100 && (key == Keys::Up || key == Keys::Down ||
key == Keys::Left
|| key == Keys::Right)){
KeyDown(0, new KeyEventArgs(key));
}
return false;
}
};
}
[/code]
Ben Voigt - 14 May 2007 19:18 GMT
> Hi T,
>
[quoted text clipped - 15 lines]
> native C++. So did you explicitly inherit private from Panel?
> Alternatively you could try to explicitly inherit with "public Panel"
.NET doesn't allow private inheritance.
> Otherwise this could indicate a compiler bug.
No, it's the same in C# and VC++ 2005. Only the class which declares an
event can fire it. The public access refers to the ability to subscribe
handlers, not to trigger the event. Usually calling the base class has an
OnKeyDown method which you can call, resulting in the event being fired with
your parameters.
Or, you can hide the parent event as you've done, but anyone who subscribes
with a base class pointer won't see your event.
> --
> SvenC