I had a window in which I wanted to give only a glass panel (without a title and without resizing) and ran into the same problem as you. You cannot do this by setting the Window style. My solution was to set ResizeMode = "CanResize" and WindowStyle = "None" and then handle the WM_NCHITTEST event in order to convert the modified remote boundary hits to immutable boundary images. It was also necessary to change the window style to disable maximization and minimization (using Windows shortcuts) and the system menu:
private void Window_SourceInitialized(object sender, EventArgs e) { System.Windows.Interop.HwndSource source = (System.Windows.Interop.HwndSource)PresentationSource.FromVisual(this); source.AddHook(new System.Windows.Interop.HwndSourceHook(HwndSourceHook)); IntPtr hWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; IntPtr flags = GetWindowLongPtr(hWnd, -16 ); SetWindowLongPtr(hWnd, -16 , new IntPtr(flags.ToInt64() & ~(0x00010000L | 0x00020000L | 0x00080000L ))); } private static IntPtr HwndSourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case 0x0084 : IntPtr result = DefWindowProc(hwnd, msg, wParam, lParam); if (result.ToInt32() >= 10 && result.ToInt32() <= 17 ) { handled = true; return new IntPtr(18 ); } break; } return IntPtr.Zero; } [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)] private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);
This gives you a window in Windows 7 suitable for pop-ups in the notification area (like clock or volume pop-ups). BTW, you can reproduce the shading at the bottom of the popup by creating a 44-height control and setting its background:
<Control.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientStop Color="{x:Static SystemColors.GradientActiveCaptionColor}" Offset="0"/> <GradientStop Color="{x:Static SystemColors.InactiveBorderColor}" Offset="0.1"/> </LinearGradientBrush> </Control.Background>
user410387
source share