I have a TFrame on which some TEdits are placed. These edits are boxes for serial key input, as I'm trying to setup a user experience where input focus jumps from one edit box to the next, when a certain amount of characters been entered in each. That is, user do not need to press tab or click on the next edit in order to advance.
I found an example in the C++ Builder HowTo book (great book) on how to "simulate" enter press to behave like a tab press in edits and was trying to employ the same technique. However, something in my app don't work as in that example.
In the frames KeyPress event, I have the code
void __fastcall TAboutFrame::Edit1KeyPress(TObject *Sender,
System::WideChar &Key)
{
TEdit* theEdit = dynamic_cast<TEdit*>(Sender);
if(!theEdit)
{
return;
}
if(theEdit->Text.Length() >= 6)
{
//jump to next edit
Perform(WM_NEXTDLGCTL, 0, 0);
...
But the 'jump' to next control does not occur.
The main Form, the frames parent, do have key preview == true and I can set a breakpoint to see that the Perform call is indeed executed.
The tab orders on the edits are 1,2,3,4,5.
I wonder if this has todo with TFrames messaging or?
If the controls you are using descend from TWinControl (Which they should if you are using stock VCL controls), You can also use TWinControl->SetFocus() to explicitly set the focus to the desired control.