Exemple #1
0
 /// <summary>
 /// DefWndProcWrapper is a wrapper around DefWndProc.  This is a workaround
 /// for WindowsSE bugs 124461 and 124455, which affect Windows XP SP2, Luna theme.
 ///
 /// HwndSubclass.SubclassWndProc is sometimes directly set as the window proc of a
 /// Window (HwndWrapper's constructor does this).  When this happens it subclasses
 /// itself on the first message it receives. Since the old window proc is itself,
 /// it saves off DefWndProc as the old window proc instead.
 ///
 /// As described by the bugs and and KB article 319740, if we set DefWndProc
 /// as the window proc of the window, we'll leak 6 GDI region objects
 /// corresponding to the Luna-themed non-client area.
 ///
 /// The reason for this is that the kernel will flag that window as a server-side
 /// window. If the WndProc replacement happens in response to a WM_NCDESTROY message
 /// (as it does in the case where Avalon is creating and closing windows), the Shell
 /// won't clean up the regions.
 ///
 /// The fix is slated for XP SP3, so for now WPF is implementing a workaround:
 /// if we set the window proc to be a stub that calls into DefWndProc, the kernel
 /// won't set us as a server-side window.
 /// </summary>
 private static IntPtr DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
 {
     return(UnsafeNativeMethods.CallWindowProc(DefWndProc, hwnd, msg, wParam, lParam));
 }
Exemple #2
0
 /// <summary>
 ///     This method lets the user call the old WNDPROC, i.e
 ///     the next WNDPROC in the chain directly.
 /// </summary>
 /// <param name="oldWndProc">
 ///     The WndProc to call.
 /// </param>
 /// <param name="hwnd">
 ///     The window that this message was sent or posted to.
 /// </param>
 /// <param name="msg">
 ///     The message that was sent or posted.
 /// </param>
 /// <param name="wParam">
 ///     A parameter for the message that was sent or posted.
 /// </param>
 /// <param name="lParam">
 ///     A parameter for the message that was sent or posted.
 /// </param>
 /// <returns>
 ///     The value that is the result of processing the message.
 /// </returns>
 IntPtr CallOldWindowProc(IntPtr oldWndProc, IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam)
 {
     return(UnsafeNativeMethods.CallWindowProc(oldWndProc, hwnd, (int)msg, wParam, lParam));
 }