mizo hazem
mizo hazem

Reputation: 31

mfc accelerators Ctrl + doesn't work

I have mfc application where I defined keyboard ACCELERATORS It works fine when I use alphanumeric characters, but I want to define an accelerators that zoomin/zoomout while pressing on the keys +/- so I defined it as the following and it works fine

 ID1 ACCELERATORS DISCARDABLE
 {
   "+",  ID_ZOOMIN ,  ,ASCII, NOINVERT      
   "-",   ID_ZOOMIN ,ASCII, NOINVERT        
 }

Now I added a text box that can accept "+/-" as charcters but pressing on them now function as zoomin/zoomout and the characters "+/-" are not typed so I changed my implementation to have the "zoomin/zoomout" functionality only works while the control button is pressed

 ID1 ACCELERATORS DISCARDABLE
 {
   "+",  ID_ZOOMIN ,  ,ASCII, CONTROL, NOINVERT      
   "-",   ID_ZOOMIN ,ASCII, CONTROL, NOINVERT        
 }

but still pressing +/- or Ctrl + +/Ctrl + -" function as "zoomin/zoomout" and the +/- characters are not typed Note: changing ASCII to VIRTKEY doesn't solve the problem

Any ideas??

Upvotes: 2

Views: 1642

Answers (1)

9dan
9dan

Reputation: 4272

I've just tested with my Windows laptop. It seems ASCII accelerators don't support the CONTROL modifier.

Use VIRTKEY instead.

 ID1 ACCELERATORS DISCARDABLE
 {
   107,  ID_ZOOMIN,  VIRTKEY, CONTROL, NOINVERT      
   109,  ID_ZOOMOUT,  VIRTKEY, CONTROL, NOINVERT        
 }

Or specify VK_ADD for +, VK_SUBTRACT for -.

Windows Virtual-Key Codes

Upvotes: 1

Related Questions