mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 04:39:36 +02:00
lcl, win32: fix showing of windows which needs to be shown on taskbar (bug #0017561)
git-svn-id: trunk@27714 -
This commit is contained in:
parent
9f513e68e6
commit
520d367826
@ -451,6 +451,7 @@ type
|
||||
FRestoredHeight: integer;
|
||||
FShowInTaskbar: TShowInTaskbar;
|
||||
FWindowState: TWindowState;
|
||||
function GetEffectiveShowInTaskBar: TShowInTaskBar;
|
||||
function GetMonitor: TMonitor;
|
||||
function GetPixelsPerInch: Longint;
|
||||
function GetRestoredLeft: integer;
|
||||
|
@ -490,11 +490,9 @@ begin
|
||||
//"urgency" flag) so we hide it again here.
|
||||
// This is the most important place to invoke UpdateShowInTaskBar, since
|
||||
//invoking it anywhere else seeems basically useless/frequently reversed.
|
||||
if (ShowInTaskBar = stNever) or ((ShowInTaskBar = stDefault)
|
||||
and (Application.TaskBarBehavior = tbSingleButton)) then
|
||||
begin
|
||||
if (ShowInTaskBar = stNever) or
|
||||
((ShowInTaskBar = stDefault) and (Application.TaskBarBehavior = tbSingleButton)) then
|
||||
UpdateShowInTaskBar;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -814,21 +812,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCustomForm.GetEffectiveShowInTaskBar: TShowInTaskBar;
|
||||
begin
|
||||
Result := ShowInTaskBar;
|
||||
if (Result = stDefault) or (csDesigning in ComponentState) then
|
||||
case Application.TaskBarBehavior of
|
||||
tbSingleButton: Result := stNever;
|
||||
tbMultiButton: Result := stAlways;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomForm.UpdateShowInTaskBar;
|
||||
var
|
||||
Value: TShowInTaskBar;
|
||||
begin
|
||||
if (Application.MainForm = Self) or (not HandleAllocated) or (Parent<>nil)
|
||||
or (FormStyle = fsMDIChild) or (not Showing) then Exit;
|
||||
Value := ShowInTaskBar;
|
||||
if (Value = stDefault) or (csDesigning in ComponentState) then
|
||||
case Application.TaskBarBehavior of
|
||||
tbSingleButton: Value := stNever;
|
||||
tbMultiButton: Value := stAlways;
|
||||
else // nothing
|
||||
end;
|
||||
if FRealizedShowInTaskBar<>Value then begin
|
||||
FRealizedShowInTaskBar:=Value;
|
||||
if (Application.MainForm = Self) or (not HandleAllocated) or
|
||||
Assigned(Parent) or (FormStyle = fsMDIChild) or not Showing then Exit;
|
||||
Value := GetEffectiveShowInTaskBar;
|
||||
if FRealizedShowInTaskBar <> Value then
|
||||
begin
|
||||
FRealizedShowInTaskBar := Value;
|
||||
TWSCustomFormClass(WidgetSetClass).SetShowInTaskbar(Self, Value);
|
||||
end;
|
||||
end;
|
||||
@ -1951,6 +1954,7 @@ begin
|
||||
begin
|
||||
// define Parent according to PopupMode and PopupParent
|
||||
if not (csDesigning in ComponentState) and (Application.MainForm <> Self) then
|
||||
begin
|
||||
case PopupMode of
|
||||
pmNone:;
|
||||
pmAuto:
|
||||
@ -1960,6 +1964,10 @@ begin
|
||||
if (PopupParent <> nil) then
|
||||
WndParent := PopupParent.Handle;
|
||||
end;
|
||||
|
||||
if (WndParent = 0) and (GetEffectiveShowInTaskBar = stAlways) then
|
||||
ExStyle := ExStyle or WS_EX_APPWINDOW;
|
||||
end;
|
||||
Style := Style and not Cardinal(WS_GROUP or WS_TABSTOP or WS_CHILD);
|
||||
end;
|
||||
end;
|
||||
@ -2567,23 +2575,24 @@ begin
|
||||
DebugLn('[TCustomForm.UpdateShowing] END ',Name,':',Classname,' Pos=',DbgS(Left),',',DbgS(Top));
|
||||
{$ENDIF}
|
||||
// activate focus if visible
|
||||
if Showing and (not (csDestroying in ComponentState)) then begin
|
||||
if (ActiveControl = nil) and (not (csDesigning in ComponentState))
|
||||
and (Parent=nil) then begin
|
||||
if Showing and (not (csDestroying in ComponentState)) then
|
||||
begin
|
||||
if Assigned(ActiveControl) and (not (csDesigning in ComponentState)) and Assigned(Parent) then
|
||||
begin
|
||||
// automatically choose a control to focus
|
||||
{$IFDEF VerboseFocus}
|
||||
DebugLn('TCustomForm.CreateWnd ',DbgSName(Self),' Set ActiveControl := ',DbgSName(FindDefaultForActiveControl));
|
||||
{$ENDIF}
|
||||
ActiveControl := FindDefaultForActiveControl;
|
||||
end;
|
||||
if (Parent=nil)
|
||||
and (FActiveControl<>nil) and FActiveControl.HandleAllocated
|
||||
and FActiveControl.CanFocus
|
||||
and ([csLoading,csDestroying,csDesigning]*ComponentState=[]) then begin
|
||||
if (Parent=nil) and Assigned(ActiveControl) and
|
||||
ActiveControl.HandleAllocated and ActiveControl.CanFocus and
|
||||
([csLoading, csDestroying, csDesigning] * ComponentState = []) then
|
||||
begin
|
||||
{$IFDEF VerboseFocus}
|
||||
DebugLn('TCustomForm.CreateWnd A ',DbgSName(Self),' FActiveControl=',DbgSName(FActiveControl));
|
||||
{$ENDIF}
|
||||
LCLIntf.SetFocus(FActiveControl.Handle);
|
||||
LCLIntf.SetFocus(ActiveControl.Handle);
|
||||
end;
|
||||
UpdateShowInTaskBar;
|
||||
end;
|
||||
|
@ -922,10 +922,10 @@ function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD;
|
||||
begin
|
||||
Result := 0;
|
||||
case Style of
|
||||
bsDialog:
|
||||
Result := WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
|
||||
bsToolWindow, bsSizeToolWin:
|
||||
Result := WS_EX_TOOLWINDOW;
|
||||
bsDialog:
|
||||
Result := WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE;
|
||||
bsToolWindow, bsSizeToolWin:
|
||||
Result := WS_EX_TOOLWINDOW;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -272,7 +272,10 @@ begin
|
||||
Flags := BorderStyleToWin32Flags(BorderStyle);
|
||||
if AForm.Parent <> nil then
|
||||
Flags := (Flags or WS_CHILD) and not WS_POPUP;
|
||||
FlagsEx := BorderStyleToWin32FlagsEx(BorderStyle);
|
||||
// clear border style flags
|
||||
FlagsEx := FlagsEx and not (WS_EX_DLGMODALFRAME or WS_EX_WINDOWEDGE or WS_EX_TOOLWINDOW);
|
||||
// set border style flags
|
||||
FlagsEx := FlagsEx or BorderStyleToWin32FlagsEx(BorderStyle);
|
||||
if (AForm.FormStyle in fsAllStayOnTop) and
|
||||
not (csDesigning in AForm.ComponentState) then
|
||||
FlagsEx := FlagsEx or WS_EX_TOPMOST;
|
||||
@ -392,10 +395,6 @@ begin
|
||||
Height := Bounds.Bottom - Bounds.Top;
|
||||
end;
|
||||
SubClassWndProc := @CustomFormWndProc;
|
||||
if ((Application = nil) or (Application.MainForm <> lForm)) and
|
||||
( not (csDesigning in lForm.ComponentState) and
|
||||
(lForm.ShowInTaskBar = stAlways)) then
|
||||
FlagsEx := FlagsEx or WS_EX_APPWINDOW;
|
||||
if not (csDesigning in lForm.ComponentState) and lForm.AlphaBlend then
|
||||
FlagsEx := FlagsEx or WS_EX_LAYERED;
|
||||
end;
|
||||
@ -611,7 +610,7 @@ var
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AForm, 'SetShowInTaskbar') then
|
||||
Exit;
|
||||
if (Application <> nil) and (AForm = Application.MainForm) then
|
||||
if Assigned(Application) and (AForm = Application.MainForm) then
|
||||
Exit;
|
||||
|
||||
OldStyle := GetWindowLong(AForm.Handle, GWL_EXSTYLE);
|
||||
@ -620,7 +619,7 @@ begin
|
||||
NewStyle := NewStyle or WS_EX_APPWINDOW
|
||||
else
|
||||
NewStyle := NewStyle and not WS_EX_APPWINDOW;
|
||||
if OldStyle=NewStyle then exit;
|
||||
if OldStyle = NewStyle then exit;
|
||||
|
||||
// to apply this changes we need either to hide window or recreate it. Hide is
|
||||
// less difficult
|
||||
|
Loading…
Reference in New Issue
Block a user