Click here to Skip to main content
14,770,678 members
Please Sign up or sign in to vote.
4.20/5 (2 votes)
See more:
Hello , i know its a stupid question but i tried all i could find in the net and it didn't help me so i hope someone from you guys would.
So my problem is that i have a class which inherits CFrameWnd . I have in this project one Accelerator table which is loaded in the OnCreate Function. I wanted to add new key shortcut (Ctrl + C) and a handle for it.
So i made a function
afx_msg void OnEditCopy();

i called
ON_COMMAND(ID_EDIT_COPY,OnEditCopy)
into the Message map. And when i put breakpoint into the function definition it never entered in there.
So i tried removing the accelerator's entry for the shortcut and tried with OnChar and WM_CHAR but even there the program didn't stop in the function. The problem is that the rest of the entries in the Accelerator's Table work just fine, but when i add enter mine it doesn't.

Any help / ideas why it doesn't help will be welcome :)
Posted
Comments
Code-o-mat 18-May-12 10:02am
   
Does having the focus placed on different controls change anything? E.g. if you have a button, an edit, a checkbox, if you put the focus on the button and hit your hot key, then to the edit, then to the checbox...does it make any difference?
Argonia 18-May-12 10:17am
   
i tried clicking everywhere and clicking the shortcut nothing changed :(
Before few secs i tried with PreTranslateMessage and for my big surprise it worked . But i dont want to make it with this function but with Accelerator's Table. Isn't it strange ? with PreTranslateMessage works but not with WM_CHAR or accelerator *wondering*
Code-o-mat 18-May-12 10:22am
   
If you assign that same ID to another key combination, like Ctrl+D or somesuch, does it work then?
Argonia 19-May-12 1:45am
   
no :( i even tried to change some of the already assigned combinations that didn't work too
Code-o-mat 19-May-12 4:33am
   
My guess -without seeing the code- is then that your message handler might be wrong or misplaced. You say other shortcut keys work fine, are they handled the very same way as this one and at the very same message map as this one?
Argonia 19-May-12 6:43am
   
well the project is little bit big(only 9k lines the main frame :P) but yes i am sure that i am using the right message map (you cant miss it)
Well i guess i have to leave it in PreTranslateMessage :( Atleast that way it works .
Thx to everyone for your help

   
you missed to include the command in the message map, so the message wont run in your class. Is the key in your accelerator table?

Some information:

http://msdn.microsoft.com/en-us/library/s9k6yh5b(v=vs.80).aspx[^]
   
Comments
Argonia 31-May-12 2:23am
   
i didn't miss to add the command in the message map and yes the key was in my accelerator's table

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900