Skip to content

Commit

Permalink
Fix toggle taskbar hidden when window is maximized
Browse files Browse the repository at this point in the history
  • Loading branch information
charles7668 committed Sep 11, 2024
1 parent 18ee509 commit 919399c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Tiefsee/Lib/WindowAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,39 @@ public static void GlobalActivate(IntPtr interopHelper) {
private static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach);

#endregion

#region 任務欄

[StructLayout(LayoutKind.Sequential)]
public struct APPBARDATA
{
public int cbSize;
public IntPtr hWnd;
public uint uCallbackMessage;
public uint uEdge;
public RECT rc;
public int lParam;
}

[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}

[DllImport("shell32.dll", SetLastError = true)]
public static extern uint SHAppBarMessage(uint dwMessage, ref APPBARDATA pData);

// ABM_GETSTATE 用來檢查任務欄狀態的訊息
public const uint ABM_GETSTATE = 0x00000004;

// 設定任務欄的狀態,當值為 ABS_AUTOHIDE 時,表示啟用了自動隱藏
public const int ABS_AUTOHIDE = 0x1;

#endregion
}

}
1 change: 1 addition & 0 deletions Tiefsee/VW/WV_Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ public string WindowState {
set {
if (value == "Maximized") {
// WebWindow.ShowWindow(M.Handle, WebWindow.SW_MAXIMIZE);
M.ResetMaximumBound();
M.WindowState = FormWindowState.Maximized;
}
if (value == "Minimized") {
Expand Down
17 changes: 17 additions & 0 deletions Tiefsee/WebWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class WebWindow : FormNone {
///
/// </summary>
public WebWindow() {
ResetMaximumBound();
WebWindowList.Add(this);

this.FormClosed += (sender, e) => {
Expand Down Expand Up @@ -685,6 +686,22 @@ public void WindowRoundedCorners(bool enable) {
WindowAPI.WindowRoundedCorners(this.Handle, enable);
}

public void ResetMaximumBound() {
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
// 獲取任務欄狀態
uint state = SHAppBarMessage(ABM_GETSTATE, ref abd);

// 檢查是否啟用了自動隱藏
if ((state & ABS_AUTOHIDE) == ABS_AUTOHIDE) {
var bounds = Screen.FromHandle(Handle).WorkingArea;
bounds.Height -= 1;
MaximizedBounds = bounds;
}
else {
MaximizedBounds = Screen.FromHandle(Handle).WorkingArea;
}
}
}

/// <summary>
Expand Down

0 comments on commit 919399c

Please sign in to comment.