Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowing the user to press "Enter" in a TEdit 1

Status
Not open for further replies.

sassygirl

Technical User
Mar 20, 2002
16
US
Hi all,
I want to make my program user friendly by allowing the user to press "Enter" after editting a value in a TEdit box. After pressing "Enter" or the return key, I want Borland to call a function. Simple as that. Any ideas? =)

-sassygirl
 
do this in the OnKeyUp event under your TEdit (Named Edit1 in this)

void __fastcall TForm1::Edit1KeyUp(TObject *Sender, DWORD Key, /* something like that... there may be more, but I currently don't have access to BCB */)
{

if (Key == VK_RETURN)
{
/* do what you want, the user pressed enter. */
/* If you want to fire off the same function as when you pressed a button for the edit, either copy and paste the code here, or generate the button click.
F.E. if your buttons name is Button1, and you already have the button's OnClick event... write this: */

Button1Click(NULL);
/* that'll fire off the button click function */

}

} Cyprus
[noevil]
 
Hi,

I see what you're trying to do and it seems like it would work but it doesn't. This is what I have so far:

void __fastcall TForm1::HexDisplayKeyUp(TObject *Sender, WORD &Key, TShiftState Shift)
{
if (Key == VK_RETURN)
{
Write_XIOClick(Sender);
}
}

What's missing?
-sassygirl
 
Hey cyprus!

Nevermind, it works. I was confused because after hitting the return key, it would still give a "beep" sound and so I thought it didn't work. Anyhow, it's working, thanks a bunch. =)

-sassygirl
 
Hi,

Is there any way to get rid of that single beep sound after hitting return?

-sassygirl
 
try making Key = NULL immedietly after the:
Write_XIOClick(Sender);

that might do it. I've seen an answer to that question recently. Once I find it, I'll pass it along.
Cyprus
[noevil]
 
No need to search Cyprus, "Key = NULL" works, thanks! By the way, how would you search for a previously asked and answered question? It seems that the search engines available will search every forum and not just a specific forum like C++ Borland Builder.

-sassygirl
 
Go to Advanced Search, and under scope, check "Just My Forms" that will only search for your alloted keywords on your Threadminder list. Cyprus
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top