static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, PInvoke.User32.WindowMessage Msg, IntPtr wParam, IntPtr lParam);
private IntPtr NewWindowProc(IntPtr hWnd, PInvoke.User32.WindowMessage Msg, IntPtr wParam, IntPtr lParam) { switch (Msg) { case PInvoke.User32.WindowMessage.WM_GETMINMAXINFO: MINMAXINFO minMaxInfo = Marshal.PtrToStructure <MINMAXINFO>(lParam); minMaxInfo.ptMinTrackSize.x = DisplayInformation.ConvertEpxToPixel(hWnd, MinWidth); minMaxInfo.ptMinTrackSize.y = DisplayInformation.ConvertEpxToPixel(hWnd, MinHeight); minMaxInfo.ptMaxTrackSize.x = DisplayInformation.ConvertEpxToPixel(hWnd, MaxWidth); minMaxInfo.ptMaxTrackSize.y = DisplayInformation.ConvertEpxToPixel(hWnd, MaxHeight); Marshal.StructureToPtr(minMaxInfo, lParam, true); break; case PInvoke.User32.WindowMessage.WM_CLOSE: //If there is a Closing event handler and the close message wasn't send via //this event (that set IsClosing=true), the message is ignored. if (this.Closing is not null) { if (IsClosing == false) { OnClosing(); } return(IntPtr.Zero); } break; case PInvoke.User32.WindowMessage.WM_MOVE: if (this.Moving is not null) { OnWindowMoving(); } break; case PInvoke.User32.WindowMessage.WM_SIZING: if (this.Sizing is not null) { OnWindowSizing(); } break; case PInvoke.User32.WindowMessage.WM_DPICHANGED: if (this.DpiChanged is not null) { //g_dpi = HIWORD(wParam); uint dpi = HiWord(wParam); OnWindowDpiChanged((int)dpi); } break; case PInvoke.User32.WindowMessage.WM_DISPLAYCHANGE: if (this.OrientationChanged is not null) { var newOrinetation = GetWindowOrientationWin32(hWnd); if (newOrinetation != _currentOrientation) { _currentOrientation = newOrinetation; OnWindowOrientationChanged(newOrinetation); } } break; } return(CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam)); }
public static extern bool ChangeWindowMessageFilterEx(IntPtr hWnd, PInvoke.User32.WindowMessage msg, ChangeWindowMessageFilterExAction action, ref CHANGEFILTERSTRUCT changeInfo);