Board index » cppbuilder » Tab Stop Problem

Tab Stop Problem


2006-04-08 01:13:10 AM
cppbuilder17
I'm using BCB6. I have a form with several panels. Each panel has several
TEdits and a TRadioGroup. The TabStop is set to true for the TEdits and
false the the TRadioGroups. The tab still stops at the TRadioGroup. Any
suggestions on skipping the TRadioGroup when tabbing.
Thanks
 
 

Re:Tab Stop Problem

"Fred Mullen" < XXXX@XXXXX.COM >wrote:
Quote

Any suggestions on skipping the TRadioGroup when tabbing.
Knowing that tab was pressed before anything else happens
is a good place to start and the only effective place to
monitor for VK_TAB is in the TApplication::OnMessage event.
If the message is WM_KEYDOWN and the WParam is VK_TAB, tab
was pressed.
From there, you can use TScreen::ActiveControl to determine
if the currently focused control is a control that preceeds
a TRadioGroup. To simplify things, I would suggest that you
make sure that all of the TRadioGroups are at the end of the
TabOrder so that you only have one skip to handle and don't
forget that you have to also account for back-tab as well.
private:
void __fastcall AppMessage( TMsg &Msg, bool &Handled );
public:
__fastcall ~TForm1();
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
Application->OnMessage = AppMessage;
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
Application->OnMessage = NULL;
}
//-------------------------------------------------------------
void __fastcall TForm1::AppMessage( TMsg &Msg, bool &Handled )
{
if( Msg.message == WM_KEYDOWN || Msg.message == WM_KEYUP )
{
if( Msg.wParam == VK_TAB )
{
if( Screen->ActiveControl == Form2->FirstControl )
{
// check for backtab
if( (GetKeyState(VK_SHIFT)>0x7F )
{
// act only on WM_KEYDOWN
if( Msg.message == WM_KEYDOWN )
{
LastControl->SetFocus();
}
// swallow the key
Msg.wParam = 0;
}
}
else if( Screen->ActiveControl == Form2->LastControl )
{
// check for forward tab
if( (GetKeyState(VK_SHIFT) < 0x80 )
{
// act only on WM_KEYDOWN
if( Msg.message == WM_KEYDOWN )
{
FirstControl->SetFocus();
}
// swallow the key
Msg.wParam = 0;
}
}
}
}
}
//-------------------------------------------------------------
~ JD
 

Re:Tab Stop Problem

Thanks, that did it.
"JD" < XXXX@XXXXX.COM >wrote in message
Quote

"Fred Mullen" < XXXX@XXXXX.COM >wrote:
>
>Any suggestions on skipping the TRadioGroup when tabbing.

Knowing that tab was pressed before anything else happens
is a good place to start and the only effective place to
monitor for VK_TAB is in the TApplication::OnMessage event.
If the message is WM_KEYDOWN and the WParam is VK_TAB, tab
was pressed.

From there, you can use TScreen::ActiveControl to determine
if the currently focused control is a control that preceeds
a TRadioGroup. To simplify things, I would suggest that you
make sure that all of the TRadioGroups are at the end of the
TabOrder so that you only have one skip to handle and don't
forget that you have to also account for back-tab as well.

private:
void __fastcall AppMessage( TMsg &Msg, bool &Handled );
public:
__fastcall ~TForm1();
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
Application->OnMessage = AppMessage;
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
Application->OnMessage = NULL;
}
//-------------------------------------------------------------
void __fastcall TForm1::AppMessage( TMsg &Msg, bool &Handled )
{
if( Msg.message == WM_KEYDOWN || Msg.message == WM_KEYUP )
{
if( Msg.wParam == VK_TAB )
{
if( Screen->ActiveControl == Form2->FirstControl )
{
// check for backtab
if( (GetKeyState(VK_SHIFT)>0x7F )
{
// act only on WM_KEYDOWN
if( Msg.message == WM_KEYDOWN )
{
LastControl->SetFocus();
}
// swallow the key
Msg.wParam = 0;
}
}
else if( Screen->ActiveControl == Form2->LastControl )
{
// check for forward tab
if( (GetKeyState(VK_SHIFT) < 0x80 )
{
// act only on WM_KEYDOWN
if( Msg.message == WM_KEYDOWN )
{
FirstControl->SetFocus();
}
// swallow the key
Msg.wParam = 0;
}
}
}
}
}
//-------------------------------------------------------------

~ JD

 

{smallsort}