Send key to component
I'm writing an application where the user will be entering data in different languages into a TcxGrid. To facilitate entering of keys not on a normal keyboard (á or ¿) I decided to add the ability for the user to add a button, which when pressed would send a character directly to the grid.
Basically the button gets pressed, the caption on the button is the character to send to the grid. Right now my only way of doing this would be to get the active grid cell, copy the text there, append the character to add and then set the grid value to the new string. This doesn't seem ideal.
Any ideas on a clean way to do this?
If you can get the handle of the control, you can post messages to the control which indicate typing.
PostMessage(Edit1.Handle, WM_CHAR, Ord('A'), 0);
I'm sure there's a slicker way to do it, but I got your characters doing this off of using "Character Map":
const testchar1 = 'Á'; testchar2 = '¿'; begin PostMessage(Edit1.Handle, WM_CHAR, Ord(testchar1), 0); PostMessage(Edit1.Handle, WM_CHAR, Ord(testchar2), 0); end;
If you need virtual scan codes, use WM_KEYDOWN and WM_KEYUP messages.