public static GetWindowLongPtr ( |
||
hWnd | Handle to the window and, indirectly, the class to which the window belongs | |
nIndex | int | Specifies the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of an integer |
return |
/// <summary> /// Window function /// </summary> /// <param name="hwnd"></param> /// <param name="msg"></param> /// <param name="wParam"></param> /// <param name="lParam"></param> /// <param name="handled"></param> /// <returns></returns> private IntPtr WindowProc( IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (msg) { case 0x0006 /*WM_ACTIVATE*/: { if (((short)wParam.ToInt32()) == 0) { // BUG: Fix for MessageBox: without parent messagebox closes if (hwndSource != null) { if (NativeMethods.GetWindowLongPtr(lParam, NativeMethods.GWL_HWNDPARENT) == hwndSource.Handle) { break; } if (openedPopups.Count(x => x.hwndSource.Handle == lParam) == 0) { ClosePopups(0); } } } else { int index = openedPopups.IndexOf(this); ClosePopups(index + 1); Window wnd = Window.GetWindow(this); if (wnd != null) { IntPtr parentHwnd = (new WindowInteropHelper(wnd)).Handle; NativeMethods.SendMessage(parentHwnd, 0x0086, new IntPtr(1), IntPtr.Zero); } } break; } case 0x0021 /*WM_MOUSEACTIVATE*/: { int index = openedPopups.IndexOf(this); ClosePopups(index + 1); Window wnd = Window.GetWindow(this); if (wnd != null) { IntPtr parentHwnd = (new WindowInteropHelper(wnd)).Handle; NativeMethods.SendMessage(parentHwnd, 0x0086, new IntPtr(1), IntPtr.Zero); } break; } case 0x0002 /*WM_DESTROY*/: { /*if ((hwndSource != null) && (!hwndSource.IsDisposed)) * { * // Remove hook * hwndSource.RemoveHook(WindowProc); * hwndSource = null; * }*/ break; } } return(IntPtr.Zero); }