DennisWoo
November 29th, 2005, 08:59 AM
Environment: XP Pro SP2, VS.Net2003
I am setting up some context menu items that have shortcut keys associated to them. The shortcut keys are: Shortcut::CtrlShift0 to Shortcut::ChrlShift9. This how I implement it:
for( i=0 ; i<10 ; ++i )
{
miShortcuts[i]->Index = i ;
miShortcuts[i]->Text = String::Concat(S"Shortcut ", i.ToString() ) ;
miShortcuts[i]->Shortcut = static_cast<Shortcut>(*dynamic_cast<Shortcut *>(Enum::Parse(__typeof(Shortcut), String::Concat(S"CtrlShift",i.ToString())))) ;
miShortcuts[i]->Click += new System::EventHandler( this, MenuItem_Shortcut_Click ) ;
}
When I compiled it, I got this error:
error C2440: 'static_cast' : cannot convert from 'System::Enum' to 'System::Windows::Forms::Shortcut'
I have tried many things but I keep ending with similar error messages. Your help is appreciated.
Thanks!:cool:
Dennis
I am setting up some context menu items that have shortcut keys associated to them. The shortcut keys are: Shortcut::CtrlShift0 to Shortcut::ChrlShift9. This how I implement it:
for( i=0 ; i<10 ; ++i )
{
miShortcuts[i]->Index = i ;
miShortcuts[i]->Text = String::Concat(S"Shortcut ", i.ToString() ) ;
miShortcuts[i]->Shortcut = static_cast<Shortcut>(*dynamic_cast<Shortcut *>(Enum::Parse(__typeof(Shortcut), String::Concat(S"CtrlShift",i.ToString())))) ;
miShortcuts[i]->Click += new System::EventHandler( this, MenuItem_Shortcut_Click ) ;
}
When I compiled it, I got this error:
error C2440: 'static_cast' : cannot convert from 'System::Enum' to 'System::Windows::Forms::Shortcut'
I have tried many things but I keep ending with similar error messages. Your help is appreciated.
Thanks!:cool:
Dennis