Ctrl + - (Ctrl + Hyphen-Minus) as a ShortCut key?

It might be natural to use Ctrl+ +, Ctrl+, -and Ctrl+ 0as shortcuts to scale the application, zoom out, and restore the default scale (usually 100%). Now, in Delphi, I can assign Ctrl+ +and Ctrl+ 0as shortcuts. The first, however, requires that the plus sign of the main part of the keyboard be used; The plus sign of the numeric keypad cannot be used.

The problem arises, however, when I want to designate Ctrl+ -as a shortcut. It just doesn't work. If I assign "Ctrl + -" in the IDE, the value stored in the property ShortCutis equal 16495. If we subtract from this ssCtrl, we get 111. The bypass, as one might assume, would consist in the appointment ShortCut := 45 + ssCtrlor, equivalently ShortCut := Menus.ShortCut(45, [ssCtrl]), because ord('-') = 45. But that does not work.

However, I found a working solution: ShortCut := 189 + ssCtrl. I choose 189 because it is the number that I get when I press the "-" key and listen to the event KeyDown.

So why am I not happy with this? Well, I'm afraid that the constant 189 is only valid on Swedish keyboards. I tried to read about it, and, as usual, the MSDN documentation is pretty clear, but then who knows how Delphi handles things.

+5
source share
3 answers

key code 189 VK_OEM_MINUSin Windows.pas, so your solution is not just for Swedes.

+6
source

proper use of the menu shortcut on the digital panel - Ctrl Num +for [+]
Ctrl Num -for [-]

there is a space between Num + and Num -

+1
source

, 16495 Ctrl + -. , 16573, Ctrl + -, .

However, you are right that it Menus.ShortCut(ord('-', [ssCtrl])does not work. It gives the value 16429 and is displayed as Ctrl+ in the menu Ins, and Ctrl+ Insworks as a shortcut.

Perhaps this is a problem with Delphi 2009 and later since they added Unicode.

0
source

All Articles