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

Handling OEM characters in KeyDown?

I need an editbox which
* has a canvas to display background image
* limited to accept a certain range of keystrokes
* prevent user from selecting its content by mouse

I descended my component from TCustomContol and captured KeyDown method:

procedure TMMEdit.KeyDown(var Key: Word; Shift: TShiftState);
begin
   if (Key = VK_Back) then begin

      if (length(fText)>0) then Delete( fText, Length(fText), 1);
   end
   else
      fText:= fText+ Char( key );

   repaint;
   inherited;
end;

My main problem is that fText:= fText+ Char( key ); doesn't work correctly for special characters like á, é, Õ, Ö.
How can I handle these OEM characters correctly?

Thanks,
Levente
0
Levente
Asked:
Levente
1 Solution
 
Slick812Commented:
hello Levente , the WM_KeyDown message is before the Keystroke is Translated to the correct Character, if you want the actual Charaters then use the WM_CHAR message. . . which is the OnKeyPress, otherwize you'll maybe need to use the ToASCII
0
 
LeventeAuthor Commented:
I should've takne closer look into Windows' messages. Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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