[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Delphi 7 - How can I make the <enter> key on a button ?

Posted on 2011-04-19
4
Medium Priority
?
900 Views
Last Modified: 2012-08-14
Basically the button needs to act like enter key on this particular Memo, is that possible?
0
Comment
Question by:John86a
  • 3
4 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35428741
this way
procedure TForm3.Button1Click(Sender: TObject);
begin
  Memo1.SetFocus;
  Keybd_Event(VK_RETURN,   1, 0, 0);
end;

Open in new window

0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35428759

Modify this to
procedure TForm3.Button1Click(Sender: TObject);
begin
  Memo1.SetFocus;
  Keybd_Event(VK_RETURN, 1, 0, 0);
  Keybd_Event(VK_RETURN, 1, KEYEVENTF_KEYUP, 0);
end;

Open in new window

0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35428805

If you want to use messages instead, do it like this
procedure TForm3.Button1Click(Sender: TObject);
begin
  PostMessage(Memo1.Handle, WM_KEYDOWN, Ord(#13), 0);
  Memo1.SetFocus;
end;

Open in new window

0
 

Author Closing Comment

by:John86a
ID: 35429205
That helped me track where my application was replacing <Enter> for <Tab> thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression

834 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