win32: set focus on first focusable control or on page itself if no such control on pagecontrol page change (bug #0012692)

git-svn-id: trunk@18213 -
This commit is contained in:
paul 2009-01-08 18:06:52 +00:00
parent 2d45ac454b
commit 69bd358a27
2 changed files with 7 additions and 2 deletions

View File

@ -275,8 +275,6 @@ var
Flags := SW_HIDE;
Windows.ShowWindow(PageHandle, Flags);
Windows.RedrawWindow(PageHandle, nil, 0, RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_ERASE);
if Showing then
NotebookFocusNewControl(Notebook, PageIndex);
Result := PageIndex;
end;
@ -2447,6 +2445,8 @@ begin
TCN_SELCHANGING:
if LMNotify.Result = 0 then
ShowHideTabPage(HWndFrom, False);
TCN_SELCHANGE:
NotebookFocusNewControl(GetWindowInfo(hwndFrom)^.WinControl as TCustomNotebook, idFrom);
end;
end;

View File

@ -229,6 +229,7 @@ var
ControlList: TFPList;
lWinControl: TWinControl;
I: integer;
FocusSet: Boolean;
begin
{ see if currently focused control is within notebook }
if not IsNotebookGroupFocused(ANotebook) then exit;
@ -239,16 +240,20 @@ begin
try
Page.GetTabOrderList(ControlList);
I := 0;
FocusSet := False;
while I < ControlList.Count do
begin
lWinControl := TWinControl(ControlList[I]);
if lWinControl.TabStop and lWinControl.Enabled and lWinControl.CanFocus then
begin
lWinControl.SetFocus;
FocusSet := True;
break;
end;
Inc(I);
end;
if not FocusSet then
Page.SetFocus;
finally
ControlList.Free;
end;