mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-26 06:08:17 +02:00
win32: start work on implementation of MainFormOnTaskBar
git-svn-id: trunk@29266 -
This commit is contained in:
parent
caf018bbb4
commit
dca336b627
@ -1950,19 +1950,22 @@ begin
|
||||
if (Parent = nil) and (ParentWindow = 0) then
|
||||
begin
|
||||
// define Parent according to PopupMode and PopupParent
|
||||
if not (csDesigning in ComponentState) and (Application.MainForm <> Self) then
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
case PopupMode of
|
||||
pmNone:;
|
||||
pmAuto:
|
||||
if (Screen.ActiveForm <> nil) then
|
||||
WndParent := Screen.ActiveForm.Handle;
|
||||
pmExplicit:
|
||||
if (PopupParent <> nil) then
|
||||
WndParent := PopupParent.Handle;
|
||||
if (Application.MainForm <> Self) then
|
||||
begin
|
||||
case PopupMode of
|
||||
pmNone:;
|
||||
pmAuto:
|
||||
if (Screen.ActiveForm <> nil) then
|
||||
WndParent := Screen.ActiveForm.Handle;
|
||||
pmExplicit:
|
||||
if (PopupParent <> nil) then
|
||||
WndParent := PopupParent.Handle;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (WndParent = 0) and (GetEffectiveShowInTaskBar = stAlways) then
|
||||
if (WndParent = 0) and
|
||||
(((Self = Application.MainForm) and Application.MainFormOnTaskBar) or (GetEffectiveShowInTaskBar = stAlways)) then
|
||||
ExStyle := ExStyle or WS_EX_APPWINDOW;
|
||||
end;
|
||||
Style := Style and not Cardinal(WS_GROUP or WS_TABSTOP or WS_CHILD);
|
||||
|
@ -784,12 +784,12 @@ var
|
||||
and (Application.MainForm <> ParentForm)
|
||||
and Application.MainForm.HandleAllocated then
|
||||
begin
|
||||
targetWindow := Application.MainForm.Handle;
|
||||
if IsWindowEnabled(targetWindow) and IsWindowVisible(targetWindow) then
|
||||
TargetWindow := Application.MainFormHandle;
|
||||
if IsWindowEnabled(TargetWindow) and IsWindowVisible(TargetWindow) then
|
||||
begin
|
||||
prevFocus := Windows.GetFocus;
|
||||
Windows.SetFocus(targetWindow);
|
||||
PLMsg^.Result := Windows.SendMessage(targetWindow, WM_SYSCOMMAND, WParam, LParam);
|
||||
PLMsg^.Result := Windows.SendMessage(TargetWindow, WM_SYSCOMMAND, WParam, LParam);
|
||||
Windows.SetFocus(prevFocus);
|
||||
WinProcess := False;
|
||||
end;
|
||||
@ -798,44 +798,56 @@ var
|
||||
|
||||
SC_MINIMIZE:
|
||||
begin
|
||||
|
||||
if (Application <> nil) and (lWinControl <> nil) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm = lWinControl) then
|
||||
Window := TWin32WidgetSet(WidgetSet).AppHandle;//redirection
|
||||
|
||||
if (Window = TWin32WidgetSet(WidgetSet).AppHandle) and
|
||||
(Application <> nil) then
|
||||
if Assigned(Application) then
|
||||
begin
|
||||
if (Application.MainForm <> nil) then
|
||||
begin
|
||||
Windows.SetWindowPos(Window, HWND_TOP,
|
||||
Application.MainForm.Left, Application.MainForm.Top,
|
||||
Application.MainForm.Width, 0, SWP_NOACTIVATE);
|
||||
if Application.MainForm.HandleAllocated then
|
||||
Windows.ShowWindow(Application.MainForm.Handle, SW_HIDE);
|
||||
end;
|
||||
if Assigned(lWinControl) and (Application.MainForm = lWinControl) and not Application.MainFormOnTaskBar then
|
||||
Window := Win32WidgetSet.AppHandle;//redirection
|
||||
|
||||
PLMsg^.Result := Windows.DefWindowProc(Window, WM_SYSCOMMAND, WParam, LParam);
|
||||
WinProcess := False;
|
||||
Application.IntfAppMinimize;
|
||||
if (Window = Win32WidgetSet.AppHandle) and not Application.MainFormOnTaskBar then
|
||||
begin
|
||||
if Assigned(Application.MainForm) then
|
||||
begin
|
||||
Windows.SetWindowPos(Window, HWND_TOP,
|
||||
Application.MainForm.Left, Application.MainForm.Top,
|
||||
Application.MainForm.Width, 0, SWP_NOACTIVATE);
|
||||
if Application.MainForm.HandleAllocated then
|
||||
Windows.ShowWindow(Application.MainFormHandle, SW_HIDE);
|
||||
end;
|
||||
|
||||
PLMsg^.Result := Windows.DefWindowProc(Window, WM_SYSCOMMAND, WParam, LParam);
|
||||
WinProcess := False;
|
||||
Application.IntfAppMinimize;
|
||||
end
|
||||
else
|
||||
if Assigned(lWinControl) and (lWinControl = Application.MainForm) then
|
||||
begin
|
||||
PLMsg^.Result := Windows.DefWindowProc(Window, WM_SYSCOMMAND, WParam, LParam);
|
||||
WinProcess := False;
|
||||
Application.IntfAppMinimize;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
SC_RESTORE:
|
||||
begin
|
||||
|
||||
if (Window = TWin32WidgetSet(WidgetSet).AppHandle) and
|
||||
(Application <> nil) then
|
||||
if Assigned(Application) then
|
||||
begin
|
||||
PLMsg^.Result := Windows.DefWindowProc(Window, WM_SYSCOMMAND, WParam, LParam);
|
||||
WinProcess := False;
|
||||
if (Application.MainForm <> nil) and Application.MainForm.HandleAllocated then
|
||||
if (Window = TWin32WidgetSet(WidgetSet).AppHandle) and not Application.MainFormOnTaskBar then
|
||||
begin
|
||||
if Application.MainForm.HandleObjectShouldBeVisible then
|
||||
Windows.ShowWindow(Application.MainForm.Handle, SW_SHOWNA);
|
||||
PLMsg^.Result := Windows.DefWindowProc(Window, WM_SYSCOMMAND, WParam, LParam);
|
||||
WinProcess := False;
|
||||
if Assigned(Application.MainForm) and Application.MainForm.HandleAllocated then
|
||||
begin
|
||||
if Application.MainForm.HandleObjectShouldBeVisible then
|
||||
Windows.ShowWindow(Application.MainFormHandle, SW_SHOWNA);
|
||||
end;
|
||||
Application.IntfAppRestore;
|
||||
end
|
||||
else
|
||||
if Assigned(lWinControl) and (lWinControl = Application.MainForm) then
|
||||
begin
|
||||
Application.IntfAppRestore;
|
||||
end;
|
||||
Application.IntfAppRestore;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1177,9 +1189,9 @@ begin
|
||||
WM_CLOSE:
|
||||
begin
|
||||
if (Window = TWin32WidgetSet(WidgetSet).AppHandle) and
|
||||
(Application.MainForm <> nil) then
|
||||
Assigned(Application.MainForm) then
|
||||
begin
|
||||
Windows.SendMessage(Application.MainForm.Handle, WM_CLOSE, 0, 0);
|
||||
Windows.SendMessage(Application.MainFormHandle, WM_CLOSE, 0, 0);
|
||||
end
|
||||
else begin
|
||||
LMessage.Msg := LM_CLOSEQUERY;
|
||||
@ -2075,15 +2087,15 @@ begin
|
||||
Status := LParam;
|
||||
end;
|
||||
//DebugLn(GetStackTrace(false));
|
||||
if assigned(lWinControl) and ((WParam<>0) or not lWinControl.Visible)
|
||||
and ((WParam=0) or lWinControl.Visible)
|
||||
and (Application<>nil) and (lWinControl=Application.MainForm) then
|
||||
if Assigned(lWinControl) and ((WParam <> 0) or not lWinControl.Visible) and
|
||||
((WParam = 0) or lWinControl.Visible) and Assigned(Application) and
|
||||
(lWinControl = Application.MainForm) and not Application.MainFormOnTaskBar then
|
||||
begin
|
||||
if WParam=0 then
|
||||
Flags := SW_HIDE
|
||||
else
|
||||
Flags := SW_SHOWNOACTIVATE;
|
||||
Windows.ShowWindow(TWin32WidgetSet(WidgetSet).FAppHandle, Flags);
|
||||
Windows.ShowWindow(TWin32WidgetSet(WidgetSet).AppHandle, Flags);
|
||||
end;
|
||||
end;
|
||||
WM_SYSCHAR:
|
||||
@ -2306,7 +2318,7 @@ begin
|
||||
if Assigned(Application.MainForm) and Application.MainForm.HandleAllocated then
|
||||
begin
|
||||
lWinControl := Application.MainForm;
|
||||
Window := Application.MainForm.Handle;
|
||||
Window := Application.MainFormHandle;
|
||||
end;
|
||||
end;
|
||||
if IsIconic(Window) then
|
||||
|
@ -176,6 +176,7 @@ type
|
||||
procedure AppSetVisible(const AVisible: Boolean); override;
|
||||
function AppRemoveStayOnTopFlags(const ASystemTopAlso: Boolean = False): Boolean; override;
|
||||
function AppRestoreStayOnTopFlags(const ASystemTopAlso: Boolean = False): Boolean; override;
|
||||
procedure AppSetMainFormOnTaskBar(const DoSet: Boolean); override;
|
||||
|
||||
function InitStockFont(AFont: TObject; AStockFont: TStockFont): Boolean; override;
|
||||
|
||||
|
@ -176,8 +176,10 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TWin32WidgetSet.AppMinimize;
|
||||
begin
|
||||
if FAppHandle <> 0 then
|
||||
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
||||
if Assigned(Application) and Application.MainFormOnTaskBar then
|
||||
Windows.SendMessage(Application.MainFormHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0)
|
||||
else
|
||||
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_MINIMIZE, 0)
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -189,7 +191,9 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TWin32WidgetSet.AppRestore;
|
||||
begin
|
||||
if FAppHandle <> 0 then
|
||||
if Assigned(Application) and Application.MainFormOnTaskBar then
|
||||
Windows.SendMessage(Application.MainFormHandle, WM_SYSCOMMAND, SC_RESTORE, 0)
|
||||
else
|
||||
Windows.SendMessage(FAppHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||
end;
|
||||
|
||||
@ -203,7 +207,7 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TWin32WidgetSet.AppBringToFront;
|
||||
begin
|
||||
if FAppHandle <> 0 then
|
||||
if (FAppHandle <> 0) and not (Assigned(Application) and Application.MainFormOnTaskBar) then
|
||||
Windows.SetForegroundWindow(FAppHandle);
|
||||
end;
|
||||
|
||||
@ -482,7 +486,7 @@ end;
|
||||
|
||||
procedure TWin32WidgetSet.AppSetVisible(const AVisible: Boolean);
|
||||
begin
|
||||
if FAppHandle <> 0 then
|
||||
if (FAppHandle <> 0) and not (Assigned(Application) and Application.MainFormOnTaskBar) then
|
||||
begin
|
||||
if AVisible then
|
||||
Windows.ShowWindow(FAppHandle, SW_SHOW)
|
||||
@ -505,6 +509,18 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TWin32WidgetSet.AppSetMainFormOnTaskBar(const DoSet: Boolean);
|
||||
begin
|
||||
// 1. Update the visibility of the TaskBar window
|
||||
if DoSet then
|
||||
ShowWindow(AppHandle, SW_HIDE)
|
||||
else
|
||||
ShowWindow(AppHandle, SW_SHOW);
|
||||
// 2. Recreate the main form - so it will (not) have an own taskbar item and WndParent = 0 (AppHandle)
|
||||
if Assigned(Application.MainForm) and Application.MainForm.HandleAllocated then
|
||||
RecreateWnd(Application.MainForm);
|
||||
end;
|
||||
|
||||
function TWin32WidgetSet.LCLPlatform: TLCLPlatform;
|
||||
begin
|
||||
Result:= lpWin32;
|
||||
@ -518,6 +534,7 @@ begin
|
||||
lcDragDockStartOnTitleClick: Result := LCL_CAPABILITY_YES;
|
||||
lcApplicationWindow: Result := LCL_CAPABILITY_YES;
|
||||
lcLMHelpSupport: Result := LCL_CAPABILITY_YES;
|
||||
lcNeedMininimizeAppWithMainForm: Result := LCL_CAPABILITY_NO;
|
||||
else
|
||||
Result := inherited;
|
||||
end;
|
||||
|
@ -160,8 +160,6 @@ begin
|
||||
Flags := CreateParams.Style;
|
||||
FlagsEx := CreateParams.ExStyle;
|
||||
Parent := CreateParams.WndParent;
|
||||
if (Parent = 0) then
|
||||
Parent := Win32WidgetSet.AppHandle;
|
||||
StrCaption := CreateParams.Caption;
|
||||
|
||||
Left := CreateParams.X;
|
||||
|
@ -370,6 +370,19 @@ begin
|
||||
// customization of Params
|
||||
with Params do
|
||||
begin
|
||||
if (Parent = 0) then
|
||||
begin
|
||||
if not Application.MainFormOnTaskBar then
|
||||
Parent := Win32WidgetSet.AppHandle
|
||||
else
|
||||
if (AWinControl <> Application.MainForm) then
|
||||
begin
|
||||
if Assigned(Application.MainForm) and Application.MainForm.HandleAllocated then
|
||||
Parent := Application.MainFormHandle
|
||||
else
|
||||
Parent := Win32WidgetSet.AppHandle;
|
||||
end;
|
||||
end;
|
||||
CalcFormWindowFlags(lForm, Flags, FlagsEx);
|
||||
pClassName := @ClsName[0];
|
||||
WindowTitle := StrCaption;
|
||||
|
Loading…
Reference in New Issue
Block a user