private DefWindowProc ( |
||
hWnd | ||
Msg | WM | |
wParam | ||
lParam | ||
return |
private static IntPtr _WndProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam) { IntPtr result = IntPtr.Zero; MessageWindow messageWindow = null; if (msg == WM.CREATE) { CREATESTRUCT createstruct = (CREATESTRUCT)Marshal.PtrToStructure(lParam, typeof(CREATESTRUCT)); messageWindow = (MessageWindow)GCHandle.FromIntPtr(createstruct.lpCreateParams).Target; MessageWindow.s_windowLookup.Add(hwnd, messageWindow); } else if (!MessageWindow.s_windowLookup.TryGetValue(hwnd, out messageWindow)) { return(NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam)); } WndProc wndProcCallback = messageWindow._wndProcCallback; if (wndProcCallback != null) { result = wndProcCallback(hwnd, msg, wParam, lParam); } else { result = NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam); } if (msg == WM.NCDESTROY) { messageWindow._Dispose(true, true); GC.SuppressFinalize(messageWindow); } return(result); }
private static IntPtr _WndProc(IntPtr hwnd, WM msg, IntPtr wParam, IntPtr lParam) { IntPtr ret = IntPtr.Zero; MessageWindow hwndWrapper = null; if (msg == WM.CREATE) { var createStruct = (CREATESTRUCT)Marshal.PtrToStructure(lParam, typeof(CREATESTRUCT)); GCHandle gcHandle = GCHandle.FromIntPtr(createStruct.lpCreateParams); hwndWrapper = (MessageWindow)gcHandle.Target; s_windowLookup.Add(hwnd, hwndWrapper); } else { if (!s_windowLookup.TryGetValue(hwnd, out hwndWrapper)) { return(NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam)); } } Assert.IsNotNull(hwndWrapper); WndProc callback = hwndWrapper.wndProcCallback; if (callback != null) { ret = callback(hwnd, msg, wParam, lParam); } else { ret = NativeMethods.DefWindowProc(hwnd, msg, wParam, lParam); } if (msg == WM.NCDESTROY) { hwndWrapper._Dispose(true, true); GC.SuppressFinalize(hwndWrapper); } return(ret); }