jpdupont
asked on
Problem with TAB on a form
On form1 I drop about 10 Edit Controls. I move to controls with TAB key. When I'm on the 10th edit, I go to the first with tab.OK.
Next, I create form2 as child (like a toolbar) of form1.
Now , when I'm on the 10th edit, if I press TAB, I go to the form2, then (next tab) to the first edit.
How avoid this ?
How exclude the form2 from the "tab circle" ?
I want to never set the focus to the form2 when I press TAB.
Next, I create form2 as child (like a toolbar) of form1.
Now , when I'm on the 10th edit, if I press TAB, I go to the form2, then (next tab) to the first edit.
How avoid this ?
How exclude the form2 from the "tab circle" ?
I want to never set the focus to the form2 when I press TAB.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, in run-time mode
Any WinControl has TabStop property (see in help)
Some controls has public TabStop property
others controls has published TabStop property
Form has PUBLIC TabStop property
write handler OnFormCreate
Form.TabStop := False;
Any WinControl has TabStop property (see in help)
Some controls has public TabStop property
others controls has published TabStop property
Form has PUBLIC TabStop property
write handler OnFormCreate
Form.TabStop := False;
Also you can override procedure GetTabOrderList(List: TList)
For example
type
TForm1 = class(TForm)
public
procedure GetTabOrderList(List: TList); override;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.GetTabOrderList(Lis t: TList);
var
I: Integer;
P: TWinControl;
begin
inherited GetTabOrderList(List);
if (ActiveControl = nil) or (ActiveControl.Parent = nil) then Exit;
P := ActiveControl.Parent;
for I := List.Count-1 downto 0 do
if P <> TControl(List[I]).Parent then List.Delete(I);
end;
// In this example "tab circle" is controls which have same parent as ActiveControl
For example
type
TForm1 = class(TForm)
public
procedure GetTabOrderList(List: TList); override;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.GetTabOrderList(Lis
var
I: Integer;
P: TWinControl;
begin
inherited GetTabOrderList(List);
if (ActiveControl = nil) or (ActiveControl.Parent = nil) then Exit;
P := ActiveControl.Parent;
for I := List.Count-1 downto 0 do
if P <> TControl(List[I]).Parent then List.Delete(I);
end;
// In this example "tab circle" is controls which have same parent as ActiveControl
ASKER
Vladika,
Thanks for the help.
1/I just try the TabStop property (OnCreate ...) : don'twork.
2/I see your comment, and I try this as soon as possible.
Thanks again
Jean-Pol
Thanks for the help.
1/I just try the TabStop property (OnCreate ...) : don'twork.
2/I see your comment, and I try this as soon as possible.
Thanks again
Jean-Pol
ASKER
Hi,
Your code don't work.
I put this in the code to create a child window :
procedure TWCombo.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
Style := (Style or WS_CHILD) and (not WS_POPUP);
WndParent := Application.MainForm.Handl e;
end;
Parent := Application.MainForm;
end;
Correct ?
Regards,
JP
Your code don't work.
I put this in the code to create a child window :
procedure TWCombo.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
Style := (Style or WS_CHILD) and (not WS_POPUP);
WndParent := Application.MainForm.Handl
end;
Parent := Application.MainForm;
end;
Correct ?
Regards,
JP
Hi!
1) From which is TWCombo inherited?
2) Is TWCombo design-time component?
3) I think CreateParams should look as
procedure TWCombo.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
Style := (Style or WS_CHILD) and (not WS_POPUP);
end;
. and when you create TWCombo ...
W := TWCombo.Create(Form1);
W.TabStop := False;
W.Parent := Form1;
......... W initialization (set height, width etc)........
4) if you wish you can send me program by email demon@dezcom.mephi.ru or
Dmitri_Ulitski@dialogbank. com and I try to help you
5) sorry for english :)
1) From which is TWCombo inherited?
2) Is TWCombo design-time component?
3) I think CreateParams should look as
procedure TWCombo.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do
Style := (Style or WS_CHILD) and (not WS_POPUP);
end;
. and when you create TWCombo ...
W := TWCombo.Create(Form1);
W.TabStop := False;
W.Parent := Form1;
......... W initialization (set height, width etc)........
4) if you wish you can send me program by email demon@dezcom.mephi.ru or
Dmitri_Ulitski@dialogbank.
5) sorry for english :)
Answer is
1) use TabStop property to exclude/include control from/in "tab circle"
2) use GetTabOrderList for full "tab circle" control
1) use TabStop property to exclude/include control from/in "tab circle"
2) use GetTabOrderList for full "tab circle" control
ASKER