BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

trapping the tab key

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Jim Boisclair
Guest





PostPosted: Mon Jun 28, 2004 12:12 am    Post subject: trapping the tab key Reply with quote



How does one trap a tab key event in a TEdit?

TIA JBB

Back to top
Dirk Schnitzler
Guest





PostPosted: Mon Jun 28, 2004 6:59 am    Post subject: Re: trapping the tab key Reply with quote



Hi Jim.

If you don´t care about the mouse, try using
"OnExit" instead of "OnKeyPress" (I guess you´re
using now).

Greetz, Dirk.


--
dschnitzler at ac-magnetic dot de


"Jim Boisclair" <bois (AT) ix (DOT) netcom.com> schrieb im Newsbeitrag
news:40df62e4 (AT) newsgroups (DOT) borland.com...
Quote:
How does one trap a tab key event in a TEdit?

TIA JBB




Back to top
JD
Guest





PostPosted: Mon Jun 28, 2004 7:56 am    Post subject: Re: trapping the tab key Reply with quote




Jim Boisclair <bois (AT) ix (DOT) netcom.com> wrote:
Quote:
How does one trap a tab key event in a TEdit?

You can't because VK_TAB never reaches the edit. The only
reliable way that I've been able to do what you want is to
intercept the keypress at the application level using the
Application's OnMessage event:

//--- in the main form's header -------------------------------
private: // User declarations
void __fastcall AppMessage( TMsg &Msg, bool &Handled );


//--- in the main form ----------------------------------------
__fastcall TMain::TMain(TComponent* Owner) : TForm(Owner)
{
Application->OnMessage = AppMessage;
}
//-------------------------------------------------------------
void __fastcall TMain::AppMessage( TMsg &Msg, bool &Handled )
{
if( Msg.message == WM_KEYDOWN || Msg.message == WM_KEYUP )
{
if( Msg.wParam == VK_TAB )
{
if( Msg.message == WM_KEYDOWN )
{
if( (GetKeyState(VK_SHIFT) & 0x80) == 0x80 )
{
// it's a back tab
}
}
// set the key to nothing
Msg.wParam = 0;
}
}
}
//-------------------------------------------------------------

You can determine the control that has focus using the
TScreen's ActiveControl property:

if( Screen->ActiveControl == Form2->Edit1 )
{
//
}

or

if( dynamic_cast<TEdit*>(Screen->ActiveControl) )
{
// it's a TEdit that has focus
}

~ JD


Back to top
Corey Murtagh
Guest





PostPosted: Mon Jun 28, 2004 10:01 am    Post subject: Re: trapping the tab key Reply with quote

JD wrote:
Quote:
Jim Boisclair <bois (AT) ix (DOT) netcom.com> wrote:

How does one trap a tab key event in a TEdit?

You can't because VK_TAB never reaches the edit. The only
reliable way that I've been able to do what you want is to
intercept the keypress at the application level using the
Application's OnMessage event:

Another method that works for me (on BCB4, still) is binding Tab to an
action. This is useful if you have a small number of controls that you
want special Tab key processing for, since you can conditionally enable
the action. It also saves messing around with key messages to figure
out which key combo is being pressed... so you don't have to implicitly
check for Ctrl-Tab and Shift-Tab.

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

Back to top
Jim Boisclair
Guest





PostPosted: Mon Jun 28, 2004 5:56 pm    Post subject: Re: trapping the tab key Reply with quote

Acually, I've used everything I can think of; Keyup, down, onchange,on
exit and nada for a response from any of them. I'm BCB5 btw. But
thanks for your help.

JBB


Back to top
Jim Boisclair
Guest





PostPosted: Mon Jun 28, 2004 6:04 pm    Post subject: Re: trapping the tab key Reply with quote

OK, as I was telling Dirk, I can't get any of the usual suspects to
respond so I'm goin with you. Thanks. JBB
Quote:



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.