public static IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { if (_onMSNET) return SendMessage_Win32 (hwnd, (int) message, wParam, lParam); else return (IntPtr) InvokeMethod ("SendMessage", new object[] { hwnd, message, wParam, lParam }); }
public static IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { Assembly assembly = Assembly.Load (Consts.AssemblySystem_Windows_Forms); Type refType = assembly.GetType ("System.Windows.Forms.Message&"); object[] args = new object[] { Message.Create (hwnd, (int)message, wParam, lParam) }; InvokeMethod ("SendMessage", args, new Type[] { refType }); return ((Message)args[0]).Result; }
private extern static bool Win32PostMessage(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
private extern static IntPtr Win32DefWindowProc(IntPtr hWnd, Msg Msg, IntPtr wParam, IntPtr lParam);
internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { return Win32SendMessage(hwnd, message, wParam, lParam); }
// For WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN, WM_XBUTTONDOWN // WM_CREATE and WM_DESTROY causes void SendParentNotify(IntPtr child, Msg cause, int x, int y) { Hwnd hwnd; if (child == IntPtr.Zero) { return; } hwnd = Hwnd.GetObjectFromWindow (child); if (hwnd == null) { return; } if (hwnd.Handle == IntPtr.Zero) { return; } if (ExStyleSet ((int) hwnd.initial_ex_style, WindowExStyles.WS_EX_NOPARENTNOTIFY)) { return; } if (hwnd.Parent == null) { return; } if (hwnd.Parent.Handle == IntPtr.Zero) { return; } if (cause == Msg.WM_CREATE || cause == Msg.WM_DESTROY) { SendMessage(hwnd.Parent.Handle, Msg.WM_PARENTNOTIFY, Control.MakeParam((int)cause, 0), child); } else { SendMessage(hwnd.Parent.Handle, Msg.WM_PARENTNOTIFY, Control.MakeParam((int)cause, 0), Control.MakeParam(x, y)); } SendParentNotify (hwnd.Parent.Handle, cause, x, y); }
internal override bool PostMessage (IntPtr handle, Msg message, IntPtr wparam, IntPtr lparam) { XEvent xevent = new XEvent (); Hwnd hwnd = Hwnd.ObjectFromHandle(handle); xevent.type = XEventName.ClientMessage; xevent.ClientMessageEvent.display = DisplayHandle; if (hwnd != null) { xevent.ClientMessageEvent.window = hwnd.whole_window; } else { xevent.ClientMessageEvent.window = IntPtr.Zero; } xevent.ClientMessageEvent.message_type = (IntPtr) PostAtom; xevent.ClientMessageEvent.format = 32; xevent.ClientMessageEvent.ptr1 = handle; xevent.ClientMessageEvent.ptr2 = (IntPtr) message; xevent.ClientMessageEvent.ptr3 = wparam; xevent.ClientMessageEvent.ptr4 = lparam; if (hwnd != null) hwnd.Queue.EnqueueLocked (xevent); else ThreadQueue(Thread.CurrentThread).EnqueueLocked (xevent); return true; }
void WaitForHwndMessage (Hwnd hwnd, Msg message) { WaitForHwndMessage (hwnd, message, false); }
// FIXME - I think this should just enqueue directly public bool PostMessage (IntPtr handle, Msg message, IntPtr wparam, IntPtr lparam) { XEvent xevent = new XEvent (); X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle); xevent.type = XEventName.ClientMessage; xevent.ClientMessageEvent.display = display; if (hwnd != null) { xevent.ClientMessageEvent.window = hwnd.WholeWindow; } else { xevent.ClientMessageEvent.window = IntPtr.Zero; } xevent.ClientMessageEvent.message_type = Atoms.PostAtom; xevent.ClientMessageEvent.format = 32; xevent.ClientMessageEvent.ptr1 = handle; xevent.ClientMessageEvent.ptr2 = (IntPtr) message; xevent.ClientMessageEvent.ptr3 = wparam; xevent.ClientMessageEvent.ptr4 = lparam; hwnd.Queue.Enqueue (xevent); return true; }
internal static IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) { DriverDebug ("SendMessage ({0}, {1}, {2:X}, {3:X}): Called", Window (handle), message, wParam.ToInt32 (), lParam.ToInt32 ()); return driver.SendMessage (handle, message, wParam, lParam); }
internal static bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { DriverDebug ("PostMessage ({0}, {1}, {2:X}, {3:X}): Called", Window (hwnd), message, wParam.ToInt32 (), lParam.ToInt32 ()); return driver.PostMessage (hwnd, message, wParam, lParam); }
internal static IntPtr WndProc(IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) { IntPtr result = IntPtr.Zero; Message m = new Message(); m.HWnd = hWnd; m.Msg = (int)msg; m.WParam = wParam; m.LParam = lParam; m.Result = IntPtr.Zero; #if debug Console.WriteLine("NativeWindow.cs ({0}, {1}, {2}, {3}): result {4}", hWnd, msg, wParam, lParam, m.Result); #endif NativeWindow window = null; try { object current = null; lock (window_collection) { current = window_collection[hWnd]; } window = current as NativeWindow; if (current == null) window = EnsureCreated (window, hWnd); if (window != null) { window.WndProc (ref m); result = m.Result; } else if (current is ArrayList) { ArrayList windows = (ArrayList) current; lock (windows) { if (windows.Count > 0) { window = EnsureCreated ((NativeWindow)windows[0], hWnd); window.WndProc (ref m); // the first one is the control's one. all others are synthetic, // so we want only the result from the control result = m.Result; for (int i=1; i < windows.Count; i++) ((NativeWindow)windows[i]).WndProc (ref m); } } } else { result = XplatUI.DefWndProc (ref m); } } catch (Exception ex) { #if !ExternalExceptionHandler if (window != null) { if (msg == Msg.WM_PAINT && window is Control.ControlNativeWindow) { // Replace control with a red cross var control = ((Control.ControlNativeWindow)window).Owner; control.Hide (); var redCross = new Control (control.Parent, string.Empty); redCross.BackColor = Color.White; redCross.ForeColor = Color.Red; redCross.Bounds = control.Bounds; redCross.Paint += HandleRedCrossPaint; } window.OnThreadException (ex); } #else throw; #endif } #if debug Console.WriteLine("NativeWindow.cs: Message {0}, result {1}", msg, m.Result); #endif return result; }
private static extern IntPtr DispatchMessage( ref Msg msg );
private static extern bool TranslateMessage( ref Msg msg );
private static extern bool PeekMessage( out Msg msg, IntPtr handle, uint msgFilterMin, uint msgFilterMax, uint removeMsg );
internal abstract bool PostMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam);
public IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) { X11Hwnd hwnd = (X11Hwnd)Hwnd.ObjectFromHandle(handle); if (hwnd == null) return IntPtr.Zero; if (hwnd.Queue.Thread != Thread.CurrentThread) { AsyncMethodResult result; AsyncMethodData data; result = new AsyncMethodResult (); data = new AsyncMethodData (); data.Handle = hwnd.Handle; data.Method = new WndProcDelegate (NativeWindow.WndProc); data.Args = new object[] { hwnd.Handle, message, wParam, lParam }; data.Result = result; SendAsyncMethod (data); #if DriverDebug || DriverDebugThreads Console.WriteLine ("Sending {0} message across.", message); #endif return IntPtr.Zero; } else { return NativeWindow.WndProc (hwnd.Handle, message, wParam, lParam); } }
internal override bool PostMessage (IntPtr handle, Msg message, IntPtr wparam, IntPtr lparam) { return display.PostMessage (handle, message, wparam, lparam); }
// XXX this is likely shareable amongst other backends internal override IntPtr SendMessage (IntPtr handle, Msg message, IntPtr wParam, IntPtr lParam) { return display.SendMessage (handle, message, wParam, lParam); }
void ProcessMenuKey (Msg msg_type) { if (TopMenu.MenuItems.Count == 0) return; MainMenu main_menu = TopMenu as MainMenu; switch (msg_type) { case Msg.WM_SYSKEYDOWN: switch (keynav_state) { case KeyNavState.Idle: keynav_state = KeyNavState.Startup; hotkey_active = true; GrabControl.ActiveTracker = this; CurrentMenu = TopMenu; main_menu.Draw (); break; case KeyNavState.Startup: break; default: Deactivate (); main_menu.Draw (); break; } break; case Msg.WM_SYSKEYUP: switch (keynav_state) { case KeyNavState.Idle: case KeyNavState.Navigating: break; case KeyNavState.Startup: keynav_state = KeyNavState.NoPopups; SelectItem (TopMenu, TopMenu.MenuItems [0], false); break; default: Deactivate (); main_menu.Draw (); break; } break; } }
void WaitForHwndMessage (Hwnd hwnd, Msg message, bool process) { MSG msg = new MSG (); XEventQueue queue; queue = ThreadQueue(Thread.CurrentThread); queue.DispatchIdle = false; bool done = false; string key = hwnd.Handle + ":" + message; if (!messageHold.ContainsKey (key)) messageHold.Add (key, 1); else messageHold[key] = ((int)messageHold[key]) + 1; do { DebugHelper.WriteLine ("Waiting for message " + message + " on hwnd " + String.Format("0x{0:x}", hwnd.Handle.ToInt32 ())); DebugHelper.Indent (); if (PeekMessage(queue, ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) { if ((Msg)msg.message == Msg.WM_QUIT) { PostQuitMessage (0); done = true; } else { DebugHelper.WriteLine ("PeekMessage got " + msg); if (msg.hwnd == hwnd.Handle) { if ((Msg)msg.message == message) { if (process) { TranslateMessage (ref msg); DispatchMessage (ref msg); } break; } else if ((Msg)msg.message == Msg.WM_DESTROY) done = true; } TranslateMessage (ref msg); DispatchMessage (ref msg); } } done = !messageHold.ContainsKey (key) || ((int)messageHold[key] < 1) || done; } while (!done); messageHold.Remove (key); DebugHelper.Unindent (); DebugHelper.WriteLine ("Finished waiting for " + key); queue.DispatchIdle = true; }
internal override bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { MSG msg = new MSG(); msg.hwnd = hwnd; msg.message = message; msg.wParam = wParam; msg.lParam = lParam; EnqueueMessage (msg); return true; }
internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { Hwnd h; h = Hwnd.ObjectFromHandle(hwnd); if (h != null && h.queue != ThreadQueue (Thread.CurrentThread)) { AsyncMethodResult result; AsyncMethodData data; result = new AsyncMethodResult (); data = new AsyncMethodData (); data.Handle = hwnd; data.Method = new WndProcDelegate (NativeWindow.WndProc); data.Args = new object[] { hwnd, message, wParam, lParam }; data.Result = result; SendAsyncMethod (data); DriverDebug("Sending {0} message across.", message); return IntPtr.Zero; } string key = hwnd + ":" + message; if (messageHold[key] != null) messageHold[key] = ((int)messageHold[key]) - 1; return NativeWindow.WndProc(hwnd, message, wParam, lParam); }
internal override IntPtr SendMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { return NativeWindow.WndProc(hwnd, message, wParam, lParam); }
private IntPtr InternalWndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) { if (HwndCreating != null && HwndCreating.ClientWindow == IntPtr.Zero) HwndCreating.ClientWindow = hWnd; return NativeWindow.WndProc (hWnd, msg, wParam, lParam); }
private void WaitForHwndMessage (Hwnd hwnd, Msg message) { MSG msg = new MSG (); bool done = false; do { if (GetMessage(null, ref msg, IntPtr.Zero, 0, 0)) { if ((Msg)msg.message == Msg.WM_QUIT) { PostQuitMessage (0); done = true; } else { if (msg.hwnd == hwnd.Handle) { if ((Msg)msg.message == message) break; else if ((Msg)msg.message == Msg.WM_DESTROY) done = true; } TranslateMessage (ref msg); DispatchMessage (ref msg); } } } while (!done); }
internal override bool PostMessage (IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam) { return Win32PostMessage(hwnd, message, wParam, lParam); }
internal abstract IntPtr SendMessage(IntPtr hwnd, Msg message, IntPtr wParam, IntPtr lParam);
private extern static IntPtr Win32SendMessage(IntPtr hwnd, Msg msg, IntPtr wParam, IntPtr lParam);
internal static IntPtr WndProc(IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) { IntPtr result = IntPtr.Zero; Message m = new Message(); m.HWnd = hWnd; m.Msg = (int)msg; m.WParam = wParam; m.LParam = lParam; m.Result = IntPtr.Zero; #if debug Console.WriteLine("NativeWindow.cs ({0}, {1}, {2}, {3}): result {4}", hWnd, msg, wParam, lParam, m.Result); #endif NativeWindow window = null; try { object current = null; lock (window_collection) { current = window_collection[hWnd]; } window = current as NativeWindow; if (current == null) window = EnsureCreated (window, hWnd); if (window != null) { window.WndProc (ref m); result = m.Result; } else if (current is ArrayList) { ArrayList windows = (ArrayList) current; lock (windows) { if (windows.Count > 0) { window = EnsureCreated ((NativeWindow)windows[0], hWnd); window.WndProc (ref m); // the first one is the control's one. all others are synthetic, // so we want only the result from the control result = m.Result; for (int i=1; i < windows.Count; i++) ((NativeWindow)windows[i]).WndProc (ref m); } } } else { result = XplatUI.DefWndProc (ref m); } } catch (Exception ex) { #if !ExternalExceptionHandler if (window != null) window.OnThreadException (ex); #else throw; #endif } #if debug Console.WriteLine("NativeWindow.cs: Message {0}, result {1}", msg, m.Result); #endif return result; }