[WPF疑难]避免窗口最大化时遮盖任务栏

转载:http://www.cnblogs.com/zhouyinhui/archive/2008/11/04/1326188.html

WPF窗口最大化时有个很不好的现象是:如果窗口的WindowStyle被直接或间接地设置为None后(比如很多情况下你会覆盖默认的窗体样式,即不采用Windows默认的边框和最大化最等按钮,来打造个性的窗体),那么最大化窗口后,窗口将铺满整个屏幕而将任务栏盖住。这往往不符合实际要求。

这里有个不错的解决方案解决了该问题,其通过对 WM_GETMINMAXINFO(MSDN: The WM_GETMINMAXINFO message is sent to a window when the size or position of the window is about to change. An application can use this message to override the window‘s default maximized size and position, or its default minimum or maximum tracking size.) 消息挂接一个钩子来处理。其消息代码是:0x0024(更多的消息代码可以参考本文附录)

没什么好说的,直接上代码(对你要处理的窗口调用FullScreenManager.RepairWpfWindowFullScreenBehavior方法即可):

public static class FullScreenManager
    {
        public static void RepairWpfWindowFullScreenBehavior(Window wpfWindow)
        {
            if(wpfWindow == null)
            {
                return;
            }

if(wpfWindow.WindowState == WindowState.Maximized)
            {
                wpfWindow.WindowState = WindowState.Normal;
                wpfWindow.Loaded += delegate { wpfWindow.WindowState = WindowState.Maximized; };
            }

wpfWindow.SourceInitialized += delegate
            {
                IntPtr handle = (new WindowInteropHelper(wpfWindow)).Handle;
                HwndSource source = HwndSource.FromHwnd(handle);
                if(source != null)
                {
                    source.AddHook(WindowProc);
                }
            };
        }

private static IntPtr WindowProc(IntPtr hwnd,  int msg,  IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            switch (msg)
            {
                case 0x0024:
                    WmGetMinMaxInfo(hwnd, lParam);
                    handled = true;
                    break;
            }

return (IntPtr) 0;
        }

private static void WmGetMinMaxInfo(IntPtr hwnd, IntPtr lParam)
        {
            var mmi = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));

// Adjust the maximized size and position to fit the work area of the correct monitor
            int MONITOR_DEFAULTTONEAREST = 0x00000002;
            IntPtr monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);

if (monitor != IntPtr.Zero)
            {
                var monitorInfo = new MONITORINFO();
                GetMonitorInfo(monitor, monitorInfo);
                RECT rcWorkArea = monitorInfo.rcWork;
                RECT rcMonitorArea = 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);
            }

Marshal.StructureToPtr(mmi, lParam, true);
        }

[DllImport("user32")]
        internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi);

/// <summary>
        /// 
        /// </summary>
        [DllImport("User32")]
        internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);

#region Nested type: MINMAXINFO

[StructLayout(LayoutKind.Sequential)]
        internal struct MINMAXINFO
        {
            public POINT ptReserved;
            public POINT ptMaxSize;
            public POINT ptMaxPosition;
            public POINT ptMinTrackSize;
            public POINT ptMaxTrackSize;
        } ;

#endregion

#region Nested type: MONITORINFO

/// <summary>
        /// </summary>
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        internal class MONITORINFO
        {
            /// <summary>
            /// </summary>            
            public int cbSize = Marshal.SizeOf(typeof(MONITORINFO));

/// <summary>
            /// </summary>            
            public RECT rcMonitor;

/// <summary>
            /// </summary>            
            public RECT rcWork;

/// <summary>
            /// </summary>            
            public int dwFlags;
        }

#endregion

#region Nested type: POINT

/// <summary>
        /// POINT aka POINTAPI
        /// </summary>
        [StructLayout(LayoutKind.Sequential)]
        internal struct POINT
        {
            /// <summary>
            /// x coordinate of point.
            /// </summary>
            public int x;

/// <summary>
            /// y coordinate of point.
            /// </summary>
            public int y;

/// <summary>
            /// Construct a point of coordinates (x,y).
            /// </summary>
            public POINT(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }

#endregion

#region Nested type: RECT

/// <summary> Win32 </summary>
        [StructLayout(LayoutKind.Sequential, Pack = 0)]
        internal struct RECT
        {
            /// <summary> Win32 </summary>
            public int left;

/// <summary> Win32 </summary>
            public int top;

/// <summary> Win32 </summary>
            public int right;

/// <summary> Win32 </summary>
            public int bottom;

/// <summary> Win32 </summary>
            public static readonly RECT Empty;

/// <summary> Win32 </summary>
            public int Width
            {
                get { return Math.Abs(right - left); } // Abs needed for BIDI OS
            }

/// <summary> Win32 </summary>
            public int Height
            {
                get { return bottom - top; }
            }

/// <summary> Win32 </summary>
            public RECT(int left, int top, int right, int bottom)
            {
                this.left = left;
                this.top = top;
                this.right = right;
                this.bottom = bottom;
            }

/// <summary> Win32 </summary>
            public RECT(RECT rcSrc)
            {
                left = rcSrc.left;
                top = rcSrc.top;
                right = rcSrc.right;
                bottom = rcSrc.bottom;
            }

/// <summary> Win32 </summary>
            public bool IsEmpty
            {
                get
                {
                    // BUGBUG : On Bidi OS (hebrew arabic) left > right
                    return left >= right || top >= bottom;
                }
            }

/// <summary> Return a user friendly representation of this struct </summary>
            public override string ToString()
            {
                if (this == Empty)
                {
                    return "RECT {Empty}";
                }
                return "RECT { left : " + left + " / top : " + top + " / right : " + right + " / bottom : " + bottom +
                       " }";
            }

/// <summary> Determine if 2 RECT are equal (deep compare) </summary>
            public override bool Equals(object obj)
            {
                if (!(obj is Rect))
                {
                    return false;
                }
                return (this == (RECT)obj);
            }

/// <summary>Return the HashCode for this struct (not garanteed to be unique)</summary>
            public override int GetHashCode()
            {
                return left.GetHashCode() + top.GetHashCode() + right.GetHashCode() + bottom.GetHashCode();
            }

/// <summary> Determine if 2 RECT are equal (deep compare)</summary>
            public static bool operator ==(RECT rect1, RECT rect2)
            {
                return (rect1.left == rect2.left && rect1.top == rect2.top && rect1.right == rect2.right &&
                        rect1.bottom == rect2.bottom);
            }

/// <summary> Determine if 2 RECT are different(deep compare)</summary>
            public static bool operator !=(RECT rect1, RECT rect2)
            {
                return !(rect1 == rect2);
            }
        }

#endregion
    }

------------------------------------------

附录:

Windows Message Codes

Sorted by Name Sorted by Code
Message Code   Code Message
WM_ACTIVATE 0x0006   0x0000 WM_NULL
WM_ACTIVATEAPP 0x001C   0x0001 WM_CREATE
WM_AFXFIRST 0x0360   0x0002 WM_DESTROY
WM_AFXLAST 0x037F   0x0003 WM_MOVE
WM_APP 0x8000   0x0005 WM_SIZE
WM_APPCOMMAND 0x0319   0x0006 WM_ACTIVATE
WM_ASKCBFORMATNAME 0x030C   0x0007 WM_SETFOCUS
WM_CANCELJOURNAL 0x004B   0x0008 WM_KILLFOCUS
WM_CANCELMODE 0x001F   0x000A WM_ENABLE
WM_CAPTURECHANGED 0x0215   0x000B WM_SETREDRAW
WM_CHANGECBCHAIN 0x030D   0x000C WM_SETTEXT
WM_CHANGEUISTATE 0x0127   0x000D WM_GETTEXT
WM_CHAR 0x0102   0x000E WM_GETTEXTLENGTH
WM_CHARTOITEM 0x002F   0x000F WM_PAINT
WM_CHILDACTIVATE 0x0022   0x0010 WM_CLOSE
WM_CLEAR 0x0303   0x0011 WM_QUERYENDSESSION
WM_CLOSE 0x0010   0x0013 WM_QUERYOPEN
WM_COMMAND 0x0111   0x0016 WM_ENDSESSION
WM_COMMNOTIFY 0x0044   0x0012 WM_QUIT
WM_COMPACTING 0x0041   0x0014 WM_ERASEBKGND
WM_COMPAREITEM 0x0039   0x0015 WM_SYSCOLORCHANGE
WM_CONTEXTMENU 0x007B   0x0018 WM_SHOWWINDOW
WM_COPY 0x0301   0x001A WM_WININICHANGE
WM_COPYDATA 0x004A   0x001A WM_SETTINGCHANGE
WM_CREATE 0x0001   0x001B WM_DEVMODECHANGE
WM_CTLCOLORBTN 0x0135   0x001C WM_ACTIVATEAPP
WM_CTLCOLORDLG 0x0136   0x001D WM_FONTCHANGE
WM_CTLCOLOREDIT 0x0133   0x001E WM_TIMECHANGE
WM_CTLCOLORLISTBOX 0x0134   0x001F WM_CANCELMODE
WM_CTLCOLORMSGBOX 0x0132   0x0020 WM_SETCURSOR
WM_CTLCOLORSCROLLBAR 0x0137   0x0021 WM_MOUSEACTIVATE
WM_CTLCOLORSTATIC 0x0138   0x0022 WM_CHILDACTIVATE
WM_CUT 0x0300   0x0023 WM_QUEUESYNC
WM_DEADCHAR 0x0103   0x0024 WM_GETMINMAXINFO
WM_DELETEITEM 0x002D   0x0026 WM_PAINTICON
WM_DESTROY 0x0002   0x0027 WM_ICONERASEBKGND
WM_DESTROYCLIPBOARD 0x0307   0x0028 WM_NEXTDLGCTL
WM_DEVICECHANGE 0x0219   0x002A WM_SPOOLERSTATUS
WM_DEVMODECHANGE 0x001B   0x002B WM_DRAWITEM
WM_DISPLAYCHANGE 0x007E   0x002C WM_MEASUREITEM
WM_DRAWCLIPBOARD 0x0308   0x002D WM_DELETEITEM
WM_DRAWITEM 0x002B   0x002E WM_VKEYTOITEM
WM_DROPFILES 0x0233   0x002F WM_CHARTOITEM
WM_ENABLE 0x000A   0x0030 WM_SETFONT
WM_ENDSESSION 0x0016   0x0031 WM_GETFONT
WM_ENTERIDLE 0x0121   0x0032 WM_SETHOTKEY
WM_ENTERMENULOOP 0x0211   0x0033 WM_GETHOTKEY
WM_ENTERSIZEMOVE 0x0231   0x0037 WM_QUERYDRAGICON
WM_ERASEBKGND 0x0014   0x0039 WM_COMPAREITEM
WM_EXITMENULOOP 0x0212   0x003D WM_GETOBJECT
WM_EXITSIZEMOVE 0x0232   0x0041 WM_COMPACTING
WM_FONTCHANGE 0x001D   0x0044 WM_COMMNOTIFY
WM_GETDLGCODE 0x0087   0x0046 WM_WINDOWPOSCHANGING
WM_GETFONT 0x0031   0x0047 WM_WINDOWPOSCHANGED
WM_GETHOTKEY 0x0033   0x0048 WM_POWER
WM_GETICON 0x007F   0x004A WM_COPYDATA
WM_GETMINMAXINFO 0x0024   0x004B WM_CANCELJOURNAL
WM_GETOBJECT 0x003D   0x004E WM_NOTIFY
WM_GETTEXT 0x000D   0x0050 WM_INPUTLANGCHANGEREQUEST
WM_GETTEXTLENGTH 0x000E   0x0051 WM_INPUTLANGCHANGE
WM_HANDHELDFIRST 0x0358   0x0052 WM_TCARD
WM_HANDHELDLAST 0x035F   0x0053 WM_HELP
WM_HELP 0x0053   0x0054 WM_USERCHANGED
WM_HOTKEY 0x0312   0x0055 WM_NOTIFYFORMAT
WM_HSCROLL 0x0114   0x007B WM_CONTEXTMENU
WM_HSCROLLCLIPBOARD 0x030E   0x007C WM_STYLECHANGING
WM_ICONERASEBKGND 0x0027   0x007D WM_STYLECHANGED
WM_IME_CHAR 0x0286   0x007E WM_DISPLAYCHANGE
WM_IME_COMPOSITION 0x010F   0x007F WM_GETICON
WM_IME_COMPOSITIONFULL 0x0284   0x0080 WM_SETICON
WM_IME_CONTROL 0x0283   0x0081 WM_NCCREATE
WM_IME_ENDCOMPOSITION 0x010E   0x0082 WM_NCDESTROY
WM_IME_KEYDOWN 0x0290   0x0083 WM_NCCALCSIZE
WM_IME_KEYLAST 0x010F   0x0084 WM_NCHITTEST
WM_IME_KEYUP 0x0291   0x0085 WM_NCPAINT
WM_IME_NOTIFY 0x0282   0x0086 WM_NCACTIVATE
WM_IME_REQUEST 0x0288   0x0087 WM_GETDLGCODE
WM_IME_SELECT 0x0285   0x0088 WM_SYNCPAINT
WM_IME_SETCONTEXT 0x0281   0x00A0 WM_NCMOUSEMOVE
WM_IME_STARTCOMPOSITION 0x010D   0x00A1 WM_NCLBUTTONDOWN
WM_INITDIALOG 0x0110   0x00A2 WM_NCLBUTTONUP
WM_INITMENU 0x0116   0x00A3 WM_NCLBUTTONDBLCLK
WM_INITMENUPOPUP 0x0117   0x00A4 WM_NCRBUTTONDOWN
WM_INPUT 0x00FF   0x00A5 WM_NCRBUTTONUP
WM_INPUTLANGCHANGE 0x0051   0x00A6 WM_NCRBUTTONDBLCLK
WM_INPUTLANGCHANGEREQUEST 0x0050   0x00A7 WM_NCMBUTTONDOWN
WM_KEYDOWN 0x0100   0x00A8 WM_NCMBUTTONUP
WM_KEYFIRST 0x0100   0x00A9 WM_NCMBUTTONDBLCLK
WM_KEYLAST 0x0108   0x00AB WM_NCXBUTTONDOWN
WM_KEYLAST 0x0109   0x00AC WM_NCXBUTTONUP
WM_KEYUP 0x0101   0x00AD WM_NCXBUTTONDBLCLK
WM_KILLFOCUS 0x0008   0x00FF WM_INPUT
WM_LBUTTONDBLCLK 0x0203   0x0100 WM_KEYFIRST
WM_LBUTTONDOWN 0x0201   0x0100 WM_KEYDOWN
WM_LBUTTONUP 0x0202   0x0101 WM_KEYUP
WM_MBUTTONDBLCLK 0x0209   0x0102 WM_CHAR
WM_MBUTTONDOWN 0x0207   0x0103 WM_DEADCHAR
WM_MBUTTONUP 0x0208   0x0104 WM_SYSKEYDOWN
WM_MDIACTIVATE 0x0222   0x0105 WM_SYSKEYUP
WM_MDICASCADE 0x0227   0x0106 WM_SYSCHAR
WM_MDICREATE 0x0220   0x0107 WM_SYSDEADCHAR
WM_MDIDESTROY 0x0221   0x0109 WM_UNICHAR
WM_MDIGETACTIVE 0x0229   0x0109 WM_KEYLAST
WM_MDIICONARRANGE 0x0228   0x0108 WM_KEYLAST
WM_MDIMAXIMIZE 0x0225   0x010D WM_IME_STARTCOMPOSITION
WM_MDINEXT 0x0224   0x010E WM_IME_ENDCOMPOSITION
WM_MDIREFRESHMENU 0x0234   0x010F WM_IME_COMPOSITION
WM_MDIRESTORE 0x0223   0x010F WM_IME_KEYLAST
WM_MDISETMENU 0x0230   0x0110 WM_INITDIALOG
WM_MDITILE 0x0226   0x0111 WM_COMMAND
WM_MEASUREITEM 0x002C   0x0112 WM_SYSCOMMAND
WM_MENUCHAR 0x0120   0x0113 WM_TIMER
WM_MENUCOMMAND 0x0126   0x0114 WM_HSCROLL
WM_MENUDRAG 0x0123   0x0115 WM_VSCROLL
WM_MENUGETOBJECT 0x0124   0x0116 WM_INITMENU
WM_MENURBUTTONUP 0x0122   0x0117 WM_INITMENUPOPUP
WM_MENUSELECT 0x011F   0x011F WM_MENUSELECT
WM_MOUSEACTIVATE 0x0021   0x0120 WM_MENUCHAR
WM_MOUSEFIRST 0x0200   0x0121 WM_ENTERIDLE
WM_MOUSEHOVER 0x02A1   0x0122 WM_MENURBUTTONUP
WM_MOUSELAST(2K,XP,2k3) 0x020D   0x0123 WM_MENUDRAG
WM_MOUSELAST(95) 0x0209   0x0124 WM_MENUGETOBJECT
WM_MOUSELAST(NT4,98) 0x020A   0x0125 WM_UNINITMENUPOPUP
WM_MOUSELEAVE 0x02A3   0x0126 WM_MENUCOMMAND
WM_MOUSEMOVE 0x0200   0x0127 WM_CHANGEUISTATE
WM_MOUSEWHEEL 0x020A   0x0128 WM_UPDATEUISTATE
WM_MOVE 0x0003   0x0129 WM_QUERYUISTATE
WM_MOVING 0x0216   0x0132 WM_CTLCOLORMSGBOX
WM_NCACTIVATE 0x0086   0x0133 WM_CTLCOLOREDIT
WM_NCCALCSIZE 0x0083   0x0134 WM_CTLCOLORLISTBOX
WM_NCCREATE 0x0081   0x0135 WM_CTLCOLORBTN
WM_NCDESTROY 0x0082   0x0136 WM_CTLCOLORDLG
WM_NCHITTEST 0x0084   0x0137 WM_CTLCOLORSCROLLBAR
WM_NCLBUTTONDBLCLK 0x00A3   0x0138 WM_CTLCOLORSTATIC
WM_NCLBUTTONDOWN 0x00A1   0x0200 WM_MOUSEFIRST
WM_NCLBUTTONUP 0x00A2   0x0200 WM_MOUSEMOVE
WM_NCMBUTTONDBLCLK 0x00A9   0x0201 WM_LBUTTONDOWN
WM_NCMBUTTONDOWN 0x00A7   0x0202 WM_LBUTTONUP
WM_NCMBUTTONUP 0x00A8   0x0203 WM_LBUTTONDBLCLK
WM_NCMOUSEHOVER 0x02A0   0x0204 WM_RBUTTONDOWN
WM_NCMOUSELEAVE 0x02A2   0x0205 WM_RBUTTONUP
WM_NCMOUSEMOVE 0x00A0   0x0206 WM_RBUTTONDBLCLK
WM_NCPAINT 0x0085   0x0207 WM_MBUTTONDOWN
WM_NCRBUTTONDBLCLK 0x00A6   0x0208 WM_MBUTTONUP
WM_NCRBUTTONDOWN 0x00A4   0x0209 WM_MBUTTONDBLCLK
WM_NCRBUTTONUP 0x00A5   0x0209 WM_MOUSELAST(95)
WM_NCXBUTTONDBLCLK 0x00AD   0x020A WM_MOUSEWHEEL
WM_NCXBUTTONDOWN 0x00AB   0x020A WM_MOUSELAST(NT4,98)
WM_NCXBUTTONUP 0x00AC   0x020B WM_XBUTTONDOWN
WM_NEXTDLGCTL 0x0028   0x020C WM_XBUTTONUP
WM_NEXTMENU 0x0213   0x020D WM_XBUTTONDBLCLK
WM_NOTIFY 0x004E   0x020D WM_MOUSELAST(2K,XP,2k3)
WM_NOTIFYFORMAT 0x0055   0x0210 WM_PARENTNOTIFY
WM_NULL 0x0000   0x0211 WM_ENTERMENULOOP
WM_PAINT 0x000F   0x0212 WM_EXITMENULOOP
WM_PAINTCLIPBOARD 0x0309   0x0213 WM_NEXTMENU
WM_PAINTICON 0x0026   0x0214 WM_SIZING
WM_PALETTECHANGED 0x0311   0x0215 WM_CAPTURECHANGED
WM_PALETTEISCHANGING 0x0310   0x0216 WM_MOVING
WM_PARENTNOTIFY 0x0210   0x0218 WM_POWERBROADCAST
WM_PASTE 0x0302   0x0219 WM_DEVICECHANGE
WM_PENWINFIRST 0x0380   0x0220 WM_MDICREATE
WM_PENWINLAST 0x038F   0x0221 WM_MDIDESTROY
WM_POWER 0x0048   0x0222 WM_MDIACTIVATE
WM_POWERBROADCAST 0x0218   0x0223 WM_MDIRESTORE
WM_PRINT 0x0317   0x0224 WM_MDINEXT
WM_PRINTCLIENT 0x0318   0x0225 WM_MDIMAXIMIZE
WM_QUERYDRAGICON 0x0037   0x0226 WM_MDITILE
WM_QUERYENDSESSION 0x0011   0x0227 WM_MDICASCADE
WM_QUERYNEWPALETTE 0x030F   0x0228 WM_MDIICONARRANGE
WM_QUERYOPEN 0x0013   0x0229 WM_MDIGETACTIVE
WM_QUERYUISTATE 0x0129   0x0230 WM_MDISETMENU
WM_QUEUESYNC 0x0023   0x0231 WM_ENTERSIZEMOVE
WM_QUIT 0x0012   0x0232 WM_EXITSIZEMOVE
WM_RBUTTONDBLCLK 0x0206   0x0233 WM_DROPFILES
WM_RBUTTONDOWN 0x0204   0x0234 WM_MDIREFRESHMENU
WM_RBUTTONUP 0x0205   0x0281 WM_IME_SETCONTEXT
WM_RENDERALLFORMATS 0x0306   0x0282 WM_IME_NOTIFY
WM_RENDERFORMAT 0x0305   0x0283 WM_IME_CONTROL
WM_SETCURSOR 0x0020   0x0284 WM_IME_COMPOSITIONFULL
WM_SETFOCUS 0x0007   0x0285 WM_IME_SELECT
WM_SETFONT 0x0030   0x0286 WM_IME_CHAR
WM_SETHOTKEY 0x0032   0x0288 WM_IME_REQUEST
WM_SETICON 0x0080   0x0290 WM_IME_KEYDOWN
WM_SETREDRAW 0x000B   0x0291 WM_IME_KEYUP
WM_SETTEXT 0x000C   0x02A1 WM_MOUSEHOVER
WM_SETTINGCHANGE 0x001A   0x02A3 WM_MOUSELEAVE
WM_SHOWWINDOW 0x0018   0x02A0 WM_NCMOUSEHOVER
WM_SIZE 0x0005   0x02A2 WM_NCMOUSELEAVE
WM_SIZECLIPBOARD 0x030B   0x02B1 WM_WTSSESSION_CHANGE
WM_SIZING 0x0214   0x02C0 WM_TABLET_FIRST
WM_SPOOLERSTATUS 0x002A   0x02DF WM_TABLET_LAST
WM_STYLECHANGED 0x007D   0x0300 WM_CUT
WM_STYLECHANGING 0x007C   0x0301 WM_COPY
WM_SYNCPAINT 0x0088   0x0302 WM_PASTE
WM_SYSCHAR 0x0106   0x0303 WM_CLEAR
WM_SYSCOLORCHANGE 0x0015   0x0304 WM_UNDO
WM_SYSCOMMAND 0x0112   0x0305 WM_RENDERFORMAT
WM_SYSDEADCHAR 0x0107   0x0306 WM_RENDERALLFORMATS
WM_SYSKEYDOWN 0x0104   0x0307 WM_DESTROYCLIPBOARD
WM_SYSKEYUP 0x0105   0x0308 WM_DRAWCLIPBOARD
WM_TABLET_FIRST 0x02C0   0x0309 WM_PAINTCLIPBOARD
WM_TABLET_LAST 0x02DF   0x030A WM_VSCROLLCLIPBOARD
WM_TCARD 0x0052   0x030B WM_SIZECLIPBOARD
WM_THEMECHANGED 0x031A   0x030C WM_ASKCBFORMATNAME
WM_TIMECHANGE 0x001E   0x030D WM_CHANGECBCHAIN
WM_TIMER 0x0113   0x030E WM_HSCROLLCLIPBOARD
WM_UNDO 0x0304   0x030F WM_QUERYNEWPALETTE
WM_UNICHAR 0x0109   0x0310 WM_PALETTEISCHANGING
WM_UNINITMENUPOPUP 0x0125   0x0311 WM_PALETTECHANGED
WM_UPDATEUISTATE 0x0128   0x0312 WM_HOTKEY
WM_USER 0x0400   0x0317 WM_PRINT
WM_USERCHANGED 0x0054   0x0318 WM_PRINTCLIENT
WM_VKEYTOITEM 0x002E   0x0319 WM_APPCOMMAND
WM_VSCROLL 0x0115   0x031A WM_THEMECHANGED
WM_VSCROLLCLIPBOARD 0x030A   0x0358 WM_HANDHELDFIRST
WM_WINDOWPOSCHANGED 0x0047   0x035F WM_HANDHELDLAST
WM_WINDOWPOSCHANGING 0x0046   0x0360 WM_AFXFIRST
WM_WININICHANGE 0x001A   0x037F WM_AFXLAST
WM_WTSSESSION_CHANGE 0x02B1   0x0380 WM_PENWINFIRST
WM_XBUTTONDBLCLK 0x020D   0x038F WM_PENWINLAST
WM_XBUTTONDOWN 0x020B   0x0400 WM_USER
WM_XBUTTONUP 0x020C   0x8000 WM_APP

时间: 2024-10-05 13:20:01

[WPF疑难]避免窗口最大化时遮盖任务栏的相关文章

[WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口

原文:[WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口 [WPF疑难] 模式窗口被隐藏后重新显示时变成了非模式窗口 周银辉 现象: 大家可以试试下面这个很有趣但会带来Defect的现象:当我们将子窗口按照ShowDialog()的方式显示出来的时候,很明显该窗口是模式化的(即主窗口等待该窗口的返回,主窗口将不相应用户输入),但如果此时将子窗口的Visibility设置成Visibility.Hidden来隐藏窗口,然后再将Visibility设置成Visibility.Visible来

WPF 自定义的窗口拖动

WPF原有的窗口样式太丑,当我们重新定义窗口时,则需要添加一些额外的功能,如拖动~ 1.在界面上对布局元素如Grid,添加委托事件: MouseLeftButtonDown="UIElement_OnMouseLeftButtonDown" 2.委托方法中处理一下就行了: private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ButtonState==Mou

Wpf使用Winform控件后Wpf元素被Winform控件遮盖问题的解决

有人会说不建议Wpf中使用Winform控件,有人会说建议使用Winform控件在Wpf下的替代方案,然而在实际工作中由于项目的特殊需求,考虑到时间.成本等因素,往往难免会碰到在WPF中使用Winfrom控件的问题,我们知道Wpf可以通过使用WindowsFormsHost容器调用Winform控件,但是在一些场合需要将Wpf元素显示在Winform控件的上层,此时就会出现Wpf元素被Winform控件遮盖的问题. 一.场景再现 接到公司命令,在时间紧迫的情况下,需要将原来的Winform程序(

Q窗口操作函数(窗口最大化,全屏,隐藏最大化最小化按钮)

//Qt主窗口没有最小化,最大化按钮且最大化显示  int main(int argc, char *argv[]) { QApplication a(argc, argv); TestQtForWinCE w; w.setWindowFlags(w.windowFlags()& ~Qt::WindowMaximizeButtonHint& ~Qt::WindowMinimizeButtonHint); w.showMaximized(); return a.exec(); } 这里的&q

【转】WPF中的窗口的生命周期

原文地址:http://www.cnblogs.com/Jennifer/articles/1997763.html WPF中的窗口的生命周期 WPF中所有窗口的基类型都是System.Windows.Window.Window通常用于SDI窗口和对话框.Window在应用程序中除了一个设计用于托管顶级内容的控件外,就别无他物了.典型的,可以混合使用标记和代码来定义一个窗口.代码如下: 在xaml页: <Window x:Class="WPFApplication1.MainWindow&

window.open窗口居中和窗口最大化

1.window.open()参数 window.open(pageURL,name,parameters) 其中: pageURL为子窗口路径 name为子窗口句柄 parameters为窗口参数(各参数用逗号分隔),如常用的 'height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no,titlebar=no' (yes/no也可使用1/0,在

屏蔽Chrome的--ignore-certificate-errors提示及禁用扩展插件并实现窗口最大化

屏蔽WebDriver启动Chrome实例时总出现的"--ignore-certificate-errors"提示信息,同时禁用Chrome浏览器的插件,并且让浏览器窗口最大化. #!usr/bin/env python #-*- coding:utf-8 -*- #屏蔽Chrome的--ignore-certificate-errors提示及禁用扩展插件并实现窗口最大化 from selenium import webdriver from selenium.webdriver.ch

WPF window 子窗口反馈效果(抖动/阴影渐变)

原文:WPF window 子窗口反馈效果(抖动/阴影渐变) 当设置了owner的子窗口显示后,点击子窗口外部,需要一种反馈机制(反馈动画). 实现: 1.触发源 每次点击子窗口外部,即母窗口时,事件捕捉如下 HwndSource hwndSource = PresentationSource.FromVisual(this.Owner) as HwndSource;//窗口过程 hwndSource?.AddHook(WndProc); 也可以调用WindowInteropHelper,获取母

Qt无边框窗体-最大化时支持拖拽还原

目录 一.概述 二.效果展示 三.demo制作 1.设计窗体 2.双击放大 四.拖拽 五.相关文章 原文链接:Markdown模板 一.概述 用Qt进行开发界面时,既想要实现友好的用户交互又想界面漂亮,那么自定义界面就必不可少.其中有一个操作就是是我们每一个Qter开发者都要会的,而且是经常进行的. Qt::FramelessWindowHint这个属性想必大家都使用过,有些同学可能对这个属性很了解,也用的是炉火纯青,今天我们也来说说这个属性. 关于这个无边框属性网上也有一些文章,有些谈论的是b