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?

Answers


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.


Need Your Help

use a mysql query result to do another query

mysql nested-queries

I have 2 table table1 contains an userid and a postid. Table2 contains a userid and a username. I want to return all the userids with a certain postid and then use those userids to query table2 a...

jquery: make item in parent window draggable from within iframe

jquery iframe draggable

I have an issue with making an element in a parent window draggable. Im trying to make it draggable from within an iframe. There is not really a workaround, i.e. I cannot include jquery in the parent

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.