2008. április 6., vasárnap

How to change the decimal point on a numerical keypad to a comma


Problem/Question/Abstract:

Is there a way to change the decimal point (.) on the numeric keypad to a comma (,) on the application level?

Answer:

You can use a handler for the Application.OnMessage event. Changing the decimal separator produced by numpad globally:

procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
begin
  case Msg.Message of
    WM_KEYDOWN, WM_KEYUP:
      if (Msg.wparam = VK_DECIMAL) and (Odd(GetKeyState(VK_NUMLOCK))) then
      begin
        Msg.wparam := 190; { for point, use 188 for comma }
        Msg.lparam := MakeLParam(LoWord(msg.lparam), (HiWord(Msg.lparam)
          and $FE00) + MapVirtualKey(Msg.wparam, 0));
      end;
  end;
end;

Nincsenek megjegyzések:

Megjegyzés küldése