CMenu -> GetMenuString -> Get text and shortcut key seperate
-
Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea?? By calling below code, it will get both text and shortcut key and put inside a string. COwnerMenu OwnerMenu; //this is inherit from CMenu OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION); I tried to seperate it by searching "Ctrl+" But as the shortcut key might not started with Ctrl+, so i cant use this method.. Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ?? I've search through net and I cant find any solution Any help would be appreciated. Regards, KH
good
-
Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea?? By calling below code, it will get both text and shortcut key and put inside a string. COwnerMenu OwnerMenu; //this is inherit from CMenu OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION); I tried to seperate it by searching "Ctrl+" But as the shortcut key might not started with Ctrl+, so i cant use this method.. Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ?? I've search through net and I cant find any solution Any help would be appreciated. Regards, KH
good
The shortcut text is separated from the menu item text by a tab character. Just search for \t within the menu string and split it at that point.
-
The shortcut text is separated from the menu item text by a tab character. Just search for \t within the menu string and split it at that point.
-
How are you defining the menu items? Usually, you define a shortcut key for a menu item using \t and Windows displays the shortcut on the right hand side of the menu. For example, in the resource editor, you would define New as New\tCtrl+N
-
Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea?? By calling below code, it will get both text and shortcut key and put inside a string. COwnerMenu OwnerMenu; //this is inherit from CMenu OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION); I tried to seperate it by searching "Ctrl+" But as the shortcut key might not started with Ctrl+, so i cant use this method.. Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ?? I've search through net and I cant find any solution Any help would be appreciated. Regards, KH
good
You should also look at this article: http://www.codeproject.com/KB/menus/newmenuxpstyle.aspx[^] I helped the author add code to parse the accelerotor table to get the short cut keys, cutting out the need to write them in the menu initially. This also lets you have changeable keys in your software. And it's a super article before I put my nose in... Iain.
-
You should also look at this article: http://www.codeproject.com/KB/menus/newmenuxpstyle.aspx[^] I helped the author add code to parse the accelerotor table to get the short cut keys, cutting out the need to write them in the menu initially. This also lets you have changeable keys in your software. And it's a super article before I put my nose in... Iain.