mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 00:59:25 +02:00
lcl: fix focus issue with docked forms (issue #0017558)
git-svn-id: trunk@27713 -
This commit is contained in:
parent
81c0f13c5f
commit
9f513e68e6
@ -141,7 +141,7 @@ end;
|
|||||||
Focus the control. If needed, bring form to front and focus it.
|
Focus the control. If needed, bring form to front and focus it.
|
||||||
If Form is not visible or disabled raise an exception.
|
If Form is not visible or disabled raise an exception.
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomForm.FocusControl(WinControl : TWinControl);
|
procedure TCustomForm.FocusControl(WinControl: TWinControl);
|
||||||
var
|
var
|
||||||
WasActive: Boolean;
|
WasActive: Boolean;
|
||||||
begin
|
begin
|
||||||
@ -506,6 +506,9 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomForm.WMDeactivate(var Message : TLMActivate);
|
procedure TCustomForm.WMDeactivate(var Message : TLMActivate);
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF VerboseFocus}
|
||||||
|
DebugLn('TCustomForm.WMDeactivate ',DbgSName(Self));
|
||||||
|
{$ENDIF}
|
||||||
SetActive(False);
|
SetActive(False);
|
||||||
{$IFDEF EnableAsyncDeactivate}
|
{$IFDEF EnableAsyncDeactivate}
|
||||||
if Application<>nil then
|
if Application<>nil then
|
||||||
@ -1263,34 +1266,6 @@ end;
|
|||||||
TCustomForm WndProc
|
TCustomForm WndProc
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCustomForm.WndProc(var TheMessage : TLMessage);
|
procedure TCustomForm.WndProc(var TheMessage : TLMessage);
|
||||||
|
|
||||||
{-----------------------------------------------------------------------
|
|
||||||
Return if the control contain a form
|
|
||||||
-----------------------------------------------------------------------}
|
|
||||||
function ContainsForm(Control : TWinControl) : Boolean;
|
|
||||||
var
|
|
||||||
I : Integer;
|
|
||||||
Found : Boolean;
|
|
||||||
begin
|
|
||||||
Found := False;
|
|
||||||
if Control <> Nil then
|
|
||||||
begin
|
|
||||||
I := 1;
|
|
||||||
while (I <= Control.ControlCount) And (Not Found) do
|
|
||||||
begin
|
|
||||||
if (Control.Controls[I-1] Is TCustomForm)
|
|
||||||
then
|
|
||||||
Found := True
|
|
||||||
else
|
|
||||||
If (Control.Controls[I-1] Is TWinControl)
|
|
||||||
then
|
|
||||||
Found := ContainsForm(Control.Controls[I-1] As TWinControl);
|
|
||||||
Inc(I);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := Found;
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
NewActiveControl: TWinControl;
|
NewActiveControl: TWinControl;
|
||||||
NewFocus: HWND;
|
NewFocus: HWND;
|
||||||
@ -1299,11 +1274,10 @@ begin
|
|||||||
//debugln(['TCustomForm.WndProc ',dbgsname(Self)]);
|
//debugln(['TCustomForm.WndProc ',dbgsname(Self)]);
|
||||||
with TheMessage do
|
with TheMessage do
|
||||||
case Msg of
|
case Msg of
|
||||||
LM_ACTIVATE, LM_SETFOCUS, LM_KILLFOCUS:
|
LM_SETFOCUS:
|
||||||
|
if not (csDesigning in ComponentState) then
|
||||||
begin
|
begin
|
||||||
if (Msg = LM_SETFOCUS) and not (csDesigning in ComponentState) then
|
//DebugLn(['TCustomForm.WndProc ',DbgSName(Self),'Msg = LM_SETFOCUS FActiveControl=',DbgSName(FActiveControl)]);
|
||||||
begin
|
|
||||||
//DebugLn(['TCustomForm.WndProc ',DbgSName(Self),' FActiveControl=',DbgSName(FActiveControl)]);
|
|
||||||
NewActiveControl := nil;
|
NewActiveControl := nil;
|
||||||
NewFocus := 0;
|
NewFocus := 0;
|
||||||
|
|
||||||
@ -1343,8 +1317,7 @@ begin
|
|||||||
DebugLn('[TCustomForm.WndProc] ',Name,':',ClassName,' FActiveControl=',DbgSName(FActiveControl));
|
DebugLn('[TCustomForm.WndProc] ',Name,':',ClassName,' FActiveControl=',DbgSName(FActiveControl));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
LCLIntf.SetFocus(NewFocus);
|
LCLIntf.SetFocus(NewFocus);
|
||||||
if not ContainsForm(Self) then exit;
|
Exit;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
CM_EXIT:
|
CM_EXIT:
|
||||||
@ -1383,7 +1356,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
inherited WndProc(TheMessage);
|
inherited WndProc(TheMessage);
|
||||||
end;
|
end;
|
||||||
@ -2293,17 +2265,20 @@ begin
|
|||||||
// update FActiveControl
|
// update FActiveControl
|
||||||
if (FDesigner = nil) and (not (csLoading in ComponentState)) then
|
if (FDesigner = nil) and (not (csLoading in ComponentState)) then
|
||||||
begin
|
begin
|
||||||
if Control <> Self then begin
|
if Control <> Self then
|
||||||
|
begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
if FActiveControl<>Control then
|
if FActiveControl<>Control then
|
||||||
debugln(['TCustomForm.SetFocusedControl ',DbgSName(Self),' OldActiveControl=',DbgSName(FActiveControl),' New=',DbgSName(Control)]);
|
debugln(['TCustomForm.SetFocusedControl ',DbgSName(Self),' OldActiveControl=',DbgSName(FActiveControl),' New=',DbgSName(Control)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FActiveControl := Control;
|
FActiveControl := Control;
|
||||||
if FActiveControl<>nil then
|
if Assigned(FActiveControl) then
|
||||||
FreeNotification(FActiveControl);
|
FreeNotification(FActiveControl);
|
||||||
end else begin
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
if FActiveControl<>nil then
|
if Assigned(FActiveControl) then
|
||||||
debugln(['TCustomForm.SetFocusedControl ',DbgSName(Self),' OldActiveControl=',DbgSName(FActiveControl),' New=',DbgSName(Control)]);
|
debugln(['TCustomForm.SetFocusedControl ',DbgSName(Self),' OldActiveControl=',DbgSName(FActiveControl),' New=',DbgSName(Control)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FActiveControl := nil;
|
FActiveControl := nil;
|
||||||
|
Loading…
Reference in New Issue
Block a user