public EventArgsWindowSizing(Rectangle rect, EnumSizeEdge edge) { Rectangle = rect; SizeEdge = edge; }
public void OnWindowEvent(int msg, string[] ss) { const int WM_ACTIVATEAPP = 0x001C; const int WM_ACTIVATE = 0x0006; const int WM_SETFOCUS = 0x0007; const int WM_SYSCOMMAND = 0x0112; const int WM_ENTERSIZEMOVE = 0x0231; const int WM_EXITSIZEMOVE = 0x0232; const int WM_SIZING = 0x0214; const int WM_SIZE = 0x0005; const int WM_KILLFOCUS = 0x0008; const int WM_WINDOWPOSCHANGING = 0x0046; const int WM_WINDOWPOSCHANGED = 0x0047; switch (msg) { case WM_ACTIVATEAPP: if (ApplicationActivate != null) { if (ss.Length > 2) { bool b = (ss[1].Length == 1 && ss[1][0] == '1'); int id = int.Parse(ss[2]); ApplicationActivate(this, new EventArgsApplicationActivate(b, id)); } } break; case WM_ACTIVATE: if (WindowActivate != null) { if (ss.Length > 3) { bool bMinimize = (ss[1].Length == 1 && ss[1][0] == '1'); int n = int.Parse(ss[2]); IntPtr id = new IntPtr(int.Parse(ss[3])); bool b2 = (n == 2); bool b1 = (n != 0); WindowActivate(this, new EventArgsWindowActivate(b1, b2, bMinimize, id)); } } break; case WM_SETFOCUS: if (WindowGotFocus != null) { if (ss.Length > 1) { IntPtr id = new IntPtr(int.Parse(ss[1])); WindowGotFocus(this, new EventArgsWindowFocus(id, true)); } } break; case WM_SYSCOMMAND: if (SystemCommand != null) { if (ss.Length > 1) { int n = int.Parse(ss[1]); EnumSystemCommand cmd = (EnumSystemCommand)n; SystemCommand(this, new EventArgsSystemCommand(cmd)); } } break; case WM_ENTERSIZEMOVE: if (EnterSizeMove != null) { EnterSizeMove(this, EventArgs.Empty); } break; case WM_EXITSIZEMOVE: if (ExitSizeMove != null) { ExitSizeMove(this, EventArgs.Empty); } break; case WM_SIZING: if (WindowSizing != null) { if (ss.Length > 5) { int n = int.Parse(ss[1]); EnumSizeEdge edge = (EnumSizeEdge)n; int x = int.Parse(ss[2]); int y = int.Parse(ss[3]); int w = int.Parse(ss[4]); int h = int.Parse(ss[5]); WindowSizing(this, new EventArgsWindowSizing(new Rectangle(x, y, w, h), edge)); } } break; case WM_SIZE: if (WindowResized != null || WindowResizeOrMove != null) { if (ss.Length > 3) { if (WindowResized != null) { int n = int.Parse(ss[1]); EnumWindowSizeType edge = (EnumWindowSizeType)n; int w = int.Parse(ss[2]); int h = int.Parse(ss[3]); WindowResized(this, new EventArgsWindowSized(edge, new Size(w, h))); } if (WindowResizeOrMove != null) { WindowResizeOrMove(this, EventArgs.Empty); } } } break; case WM_KILLFOCUS: if (WindowKillFocus != null) { if (ss.Length > 1) { IntPtr id = new IntPtr(int.Parse(ss[1])); WindowKillFocus(this, new EventArgsWindowFocus(id, false)); } } break; case WM_WINDOWPOSCHANGING: if (WindowPositionChanging != null) { if (ss.Length > 7) { int x = int.Parse(ss[1]); int y = int.Parse(ss[2]); int w = int.Parse(ss[3]); int h = int.Parse(ss[4]); int f = int.Parse(ss[5]); EnumWindowPositionChangeStyle changeStyle = (EnumWindowPositionChangeStyle)f; IntPtr hnd = new IntPtr(int.Parse(ss[6])); IntPtr hAfter = IntPtr.Zero; EnumWindowRelativePostion rp = EnumWindowRelativePostion.HWND_TOP; int nf = int.Parse(ss[7]); if (nf < 2) { rp = (EnumWindowRelativePostion)nf; } else { hAfter = new IntPtr(nf); } WindowPositionChanging(this, new EventArgsWindowPositionChange(new Point(x, y), new Size(w, h), changeStyle, hnd, hAfter, rp)); } } break; case WM_WINDOWPOSCHANGED: if (WindowPositionChanged != null || WindowResizeOrMove != null) { if (ss.Length > 7) { int x = int.Parse(ss[1]); int y = int.Parse(ss[2]); int w = int.Parse(ss[3]); int h = int.Parse(ss[4]); int f = int.Parse(ss[5]); EnumWindowPositionChangeStyle changeStyle = (EnumWindowPositionChangeStyle)f; IntPtr hnd = new IntPtr(int.Parse(ss[6])); IntPtr hAfter = IntPtr.Zero; EnumWindowRelativePostion rp = EnumWindowRelativePostion.HWND_TOP; int nf = int.Parse(ss[7]); if (nf < 2) { rp = (EnumWindowRelativePostion)nf; } else { hAfter = new IntPtr(nf); } EventArgsWindowPositionChange e = new EventArgsWindowPositionChange(new Point(x, y), new Size(w, h), changeStyle, hnd, hAfter, rp); if (WindowPositionChanged != null) { WindowPositionChanged(this, e); } if (WindowResizeOrMove != null) { if (e.IsResizedOrMoved) { WindowResizeOrMove(this, EventArgs.Empty); } } } } break; } }