• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

On screen keyboard - Russian

Hi Experts
I have an application that uses an on-screen keyboard - I pick up the caption on each button, and use it as the upper case character.  So I can use the translation manager to change keyboard format.
Now I need to do this for Russian.  What is the best way to map the cyrillic characters?  If I use the old code, the mapping is not correct.
Thanks
procedure TKbdForm.Button1Click(Sender: TObject);
var
  sx : ShortString;
  n  : integer;
  lang : integer;
  c1   : integer;
begin
    if Sender is TButton then
    begin
      EntryBox.SetFocus;
      if not firstkey then EntryBox.SelStart := EntryBox.SelLength;
      firstkey := false;
      c1 := ord(TButton(Sender).Caption[1]);
      lang := Sysutils.SysLocale.DefaultLCID and $ff;
      if lang=LANG_RUSSIAN then
      begin
        Something_different;
        keybd_event(c1,0,0,0);
      end
      else
      begin
        keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), 0, 0);
        keybd_event(ord(TButton(Sender).Caption[1]),0,0,0);
        keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), KEYEVENTF_KEYUP, 0);
      end;
    end;
end;

Open in new window

0
diver999
Asked:
diver999
  • 3
  • 2
1 Solution
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
What about changing the Font.charset to russian?

just from head, something like

...
 if lang=LANG_RUSSIAN then
      begin
        TButton(Sender).Font.Charset := RUSSIAN_CHARSET;
        keybd_event(ord(TButton(Sender).Caption[1]),0,0,0);
      end
      else
      begin
...
0
 
diver999Author Commented:
I tried this.
Captions "A", "B", etc come up as russian characters
But russian characters are not displayed - c1 > 127.   (c1=ord(Tbutton(Sender).caption[1])
Any other ideas ??
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
Why are you using the ord(chr) stuff?

Try using VKKeySkan that returns the right character translation for the virtual key code

keybd_event(VKKeySkan(TButton(Sender).Caption[1]),0,0,0);
0
 
diver999Author Commented:
OK - that's much better
I try to write the string to a Paradox database alpha field but it comes out "#####"
Do you want me to post another question for this ?
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
It' should depend on the Table Language checked in your BDE Configuration.
In a Russian System it should be Pdox ANSI Cyrillic
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now