internal void AssignHandle(IntPtr handle, bool assignUniqueID) { lock (this) { CheckReleased(); Debug.Assert(handle != IntPtr.Zero, "handle is 0"); Handle = handle; _priorWindowProcHandle = User32.GetWindowLong(this, User32.GWL.WNDPROC); Debug.Assert(_priorWindowProcHandle != IntPtr.Zero); Debug.WriteLineIf( WndProcChoice.TraceVerbose, WndProcShouldBeDebuggable ? "Using debuggable wndproc" : "Using normal wndproc"); _windowProc = new User32.WNDPROC(Callback); AddWindowToTable(handle, this); // Set the NativeWindow window procedure delegate and get back the native pointer for it. User32.SetWindowLong(this, User32.GWL.WNDPROC, _windowProc); _windowProcHandle = User32.GetWindowLong(this, User32.GWL.WNDPROC); // This shouldn't be possible. Debug.Assert(_priorWindowProcHandle != _windowProcHandle, "Uh oh! Subclassed ourselves!!!"); if (assignUniqueID && ((User32.WS)PARAM.ToUInt(User32.GetWindowLong(this, User32.GWL.STYLE))).HasFlag(User32.WS.CHILD) && User32.GetWindowLong(this, User32.GWL.ID) == IntPtr.Zero) { User32.SetWindowLong(this, User32.GWL.ID, handle); } if (_suppressedGC) { GC.ReRegisterForFinalize(this); _suppressedGC = false; } OnHandleChange(); } }
public unsafe void ToUInt_x64_Result() { Assert.Equal((uint)0x01020304, PARAM.ToUInt(unchecked ((nint)0x0506070801020304))); Assert.Equal((uint)0xF1F2F3F4, PARAM.ToUInt(unchecked ((nint)0xF5F6F7F8F1F2F3F4))); }
public unsafe void ToUInt_x32_Result() { Assert.Equal((uint)0x01020304, PARAM.ToUInt((nint)0x01020304)); Assert.Equal((uint)0xF1F2F3F4, PARAM.ToUInt(unchecked ((nint)0xF1F2F3F4))); }