Handling OEM characters in KeyDown?

Posted on 2003-04-01
Medium Priority
Last Modified: 2012-05-04
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);
   if (Key = VK_Back) then begin

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


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?

Question by:Levente
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 34

Accepted Solution

Slick812 earned 1000 total points
ID: 8249267
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

Author Comment

ID: 8261463
I should've takne closer look into Windows' messages. Thanks

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question