2

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??

Abhishek
  • 6,912
  • 14
  • 59
  • 85
mizo hazem
  • 31
  • 8

1 Answers1

1

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

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
9dan
  • 4,222
  • 2
  • 29
  • 44
  • Thanks for your replay, I have tried your proposal but now pressing on "+/-" type the characters "+/-" to the text box but the zooming in/out is not working clicking on "Ctrl + or Ctrl -" also type the characters – mizo hazem Oct 16 '14 at 09:23
  • @mizohazem Then, maybe VK_OEM_PLUS and VK_OEM_MINUS? – 9dan Oct 16 '14 at 09:28