Author: Jonas Bilinkevicius
I have a PageControl having 3 TabSheets. If this PageControl has a Panel as its
parent, then I am able navigate between the tabsheets using Ctrl-Tab (forward) or
Shift-Ctrl-Tab (backward) using the keyboard. But if the same pagecontrol has
another Tabsheet of a Pagecontrol as its parent, then I am not able to navigate
between the tabsheets of the child pagecontrol using the keyboard even though the
focus is on the child pagecontrol.
Answer:
Handling proper Ctrl-Tab and Ctrl-Shift-Tab switching of pages if several
pagecontrols are on a form:
In form declaration:
1 2 procedure CMDialogKey(var msg: TCMDialogKey); message CM_DIALOGKEY;
3 4 procedure TForm1.CMDialogKey(var msg: TCMDialogKey);
5 var6 Control: TWinControl;
7 begin8 with Msg do9 begin10 if (charcode = VK_TAB) and (GetKeyState(VK_CONTROL) < 0) then11 begin12 Control := ActiveControl;
13 while Assigned(Control) do14 if Control is TPageControl then15 begin16 Control.Perform(CM_DIALOGKEY, charcode, keydata);
17 Exit;
18 end19 else20 Control := Control.Parent;
21 end;
22 end;
23 inherited;
24 end;