unsafe static LRESULT ListBoxProcedure(WindowHandle window, WindowMessage message, WPARAM wParam, LPARAM lParam) { if (message == WindowMessage.KeyDown && (VirtualKey)wParam == VirtualKey.Return) { window.GetParent().SendMessage(WindowMessage.Command, new WPARAM(1, (ushort)ListBoxNotification.DoubleClick), (LPARAM)window); } return(WindowMethods.CallWindowProcedure(OldList, window, message, wParam, lParam)); }
public void WindowCallback_Subclass() { int value = 42; WindowClass myClass = new WindowClass { ClassName = "WindowCallback_Subclass", WindowProcedure = (window, message, wParam, lParam) => { return(value); } }; Atom atom = WindowMethods.RegisterClass(ref myClass); atom.IsValid.Should().BeTrue(); try { WindowHandle window = WindowMethods.CreateWindow(atom, null, WindowStyles.Minimize | WindowStyles.Diabled); window.IsValid.Should().BeTrue(); try { WindowMethods.SendMessage(window, WindowMessage.Activate, 0, 0).Should().Be((LRESULT)42); IntPtr previous = IntPtr.Zero; WindowProcedure subClass = (w, m, wParam, lParam) => { return(WindowMethods.CallWindowProcedure(previous, w, m, wParam, lParam)); }; value = 1999; previous = WindowMethods.SetWindowProcedure(window, subClass); WindowMethods.SendMessage(window, WindowMessage.Activate, 0, 0).Should().Be((LRESULT)1999); GC.KeepAlive(subClass); } finally { WindowMethods.DestroyWindow(window); } } finally { WindowMethods.UnregisterClass(atom, null); } }
static LRESULT ScrollProcedure(WindowHandle window, WindowMessage message, WPARAM wParam, LPARAM lParam) { int id = (int)window.GetWindowLong(WindowLong.Id).ToInt64(); switch (message) { case WindowMessage.KeyDown: if ((VirtualKey)wParam == VirtualKey.Tab) { window.GetParent().GetDialogItem( (id + ((Windows.GetKeyState(VirtualKey.Shift) & KeyState.Down) != 0 ? 2 : 1) % 3)) .SetFocus(); } break; case WindowMessage.SetFocus: idFocus = id; break; } return(WindowMethods.CallWindowProcedure(OldScroll[id], window, message, wParam, lParam)); }