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