I’ve created a window with custom chrome and everything is working fine, except when I maximize the window. Then, somehow the auto-hidden taskbar won’t pop up anymore.
I’ve tried implementing WM_GETMINMAXINFO, but even when I set the maximum size to -10 on all borders, the taskbar still won’t popup. Also, when I set it to exactly the desktop workarea bounds, WM_GETMINMAXINFO has no effect (the window is still at X,Y -7) — I have to actually set it’s height to workarea height-1 for it to work. But then, when my window is WindowStyle=”SingleBorderWindow”, sometime it randomly draws the standard Win32 gray min/max/close buttons over my design. When I use WindowStyle=”None”, then it doesn’t randomly draw over my buttons anymore, but the window loses it’s “snap to border” functionality (like bumping it into the top of the screen to maximize), so that’s not an option either.
So I’ve tried a bunch of things, but now I’m looking for an API to just pop up the auto-hidden windows taskbar, without toggling it’s auto-hide setting.
Code:
Private Function WindowProc(hwnd As IntPtr, msg As Int32, wParam As IntPtr, lParam As IntPtr, ByRef handled As Boolean) As IntPtr
Select Case msg
Case WM_GETMINMAXINFO
Dim monitor As IntPtr = MonitorFromWindow(hwnd, 2)
Dim mmi As MINMAXINFO = Marshal.PtrToStructure(lParam, GetType(MINMAXINFO))
Dim MONITORINFO As MONITORINFO = New MONITORINFO()
MONITORINFO.cbSize = Marshal.SizeOf(GetType(MONITORINFO))
GetMonitorInfo(monitor, MONITORINFO)
Dim rcWorkArea As RECT = MONITORINFO.rcWork
Dim rcMonitorArea As RECT = MONITORINFO.rcMonitor
mmi.ptMaxPosition.X = Math.Abs(rcWorkArea.Left - rcMonitorArea.Left)
mmi.ptMaxPosition.Y = Math.Abs(rcWorkArea.Top - rcMonitorArea.Top)
mmi.ptMaxSize.X = Math.Abs(rcWorkArea.Right - rcWorkArea.Left)
mmi.ptMaxSize.Y = Math.Abs(rcWorkArea.Bottom - rcWorkArea.Top) - 1
Marshal.StructureToPtr(mmi, lParam, True)
End Select
Return IntPtr.Zero
End Function
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"
Icon="Windows.ico" WindowStyle="SingleBorderWindow"
ResizeMode="CanResizeWithGrip"
Loaded="MetroWindow_Loaded" Background="#F0F0F0">
1