mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 06:22:30 +02:00
upon form show, if no activecontrol, then focus first control in tab order
git-svn-id: trunk@5851 -
This commit is contained in:
parent
02624f0d07
commit
171e00f7b4
@ -362,6 +362,29 @@ end;
|
|||||||
ShowWindow event handler.
|
ShowWindow event handler.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomForm.WMShowWindow(var message: TLMShowWindow);
|
procedure TCustomForm.WMShowWindow(var message: TLMShowWindow);
|
||||||
|
|
||||||
|
function FindFirstControl: TWinControl;
|
||||||
|
var
|
||||||
|
List: TList;
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
List := TList.Create;
|
||||||
|
Result := nil;
|
||||||
|
try
|
||||||
|
GetTabOrderList(List);
|
||||||
|
for I := 0 to List.Count - 1 do
|
||||||
|
begin
|
||||||
|
if TObject(List.Items[0]) is TWinControl then
|
||||||
|
begin
|
||||||
|
Result := TWinControl(List.Items[0]);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
List.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
DbgOut('TCustomForm.WMShowWindow A ',Name,':',ClassName,' fsShowing=',fsShowing in FFormState,' Msg.Show=',Message.Show);
|
DbgOut('TCustomForm.WMShowWindow A ',Name,':',ClassName,' fsShowing=',fsShowing in FFormState,' Msg.Show=',Message.Show);
|
||||||
@ -376,6 +399,8 @@ begin
|
|||||||
Include(FFormState, fsShowing);
|
Include(FFormState, fsShowing);
|
||||||
try
|
try
|
||||||
if Message.Show then begin
|
if Message.Show then begin
|
||||||
|
if FActiveControl = nil then
|
||||||
|
FActiveControl := FindFirstControl;
|
||||||
if (FActiveControl<>nil) and FActiveControl.HandleAllocated
|
if (FActiveControl<>nil) and FActiveControl.HandleAllocated
|
||||||
and (FActiveControl.Visible) and (FActiveControl.Enabled) then begin
|
and (FActiveControl.Visible) and (FActiveControl.Enabled) then begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
@ -1754,6 +1779,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.153 2004/08/25 17:59:06 micha
|
||||||
|
upon form show, if no activecontrol, then focus first control in tab order
|
||||||
|
|
||||||
Revision 1.152 2004/08/18 20:49:02 mattias
|
Revision 1.152 2004/08/18 20:49:02 mattias
|
||||||
simple forms can now be child controls
|
simple forms can now be child controls
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ begin
|
|||||||
TabOrder := 2;
|
TabOrder := 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// upon show, focus the edit control so people can start typing
|
// upon show, the edit control will be focused for editing, because it's
|
||||||
ActiveControl := Edit;
|
// the first in the tab order
|
||||||
If ShowModal = mrOk then
|
If ShowModal = mrOk then
|
||||||
begin
|
begin
|
||||||
Value := Edit.Text;
|
Value := Edit.Text;
|
||||||
|
Loading…
Reference in New Issue
Block a user