RSS Forums RSS
Please support our Pascal and Delphi advertiser: Programming Forums

Emulating a keyboard key press

Join Date: May 2005
Posts: 41
Reputation: mrmike is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mrmike mrmike is offline Offline
Light Poster

Re: Emulating a keyboard key press

  #4  
Sep 14th, 2005
if using an edit box then don't need to use writeln

for each button give it a tag number corresponding to the ascii value you want it to display (ie 0 = 48, 1 = 49, 2 = 50, etc)

create the following procedure

procedure TForm1.ButtonPressed(Sender: TObject);
var
index   :Integer;
begin
for index:=0 to ControlCount -1 do
begin
 if Controls[index] is TWinControl then
  if (Controls[index] as TWinControl).Focused then
   Edit1.Text:=Edit1.Text+Char(((Controls[index] as TWinControl).Tag)
end;
end;
and then set the OnClick event for each button to go to ButtonPressed

hope this helps
mrmike
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 4:40 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC