/// <summary> /// 外部プロセスで動作している Win32 ウィンドウのハンドルを指定して、<see cref="ExternalWindow"/> /// クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="hWnd">ウィンドウ ハンドル。</param> public ExternalWindow(IntPtr hWnd) { this.Handle = hWnd; if (_serviceInstance == null) { _serviceInstance = ServiceFactory.CreateInstance(); } this._external = _serviceInstance.Register(hWnd); this._external.StateChanged += this.ExternalOnStateChanged; this._external.SizeChanged += this.ExternalOnSizeChanged; this._external.WindowMoved += this.ExternalOnWindowMoved; this._external.Activated += this.ExternalOnActivated; this._external.Deactivated += this.ExternalOnDeactivated; this._external.Closed += this.ExternalOnClosed; this._rect = this.GetExtendFrameBounds(); this.IsActive = User32.GetForegroundWindow() == this.Handle; this.WindowState = WindowState.Normal; if (User32.IsIconic(hWnd)) { this.WindowState = WindowState.Minimized; } if (User32.IsZoomed(hWnd)) { this.WindowState = WindowState.Maximized; } }
private void ExternalOnStateChanged(IChromeHook sender, int state) { switch (state) { case 0: this.WindowState = WindowState.Normal; break; case 1: this.WindowState = WindowState.Minimized; break; case 2: this.WindowState = WindowState.Maximized; break; } this.StateChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// 外部プロセスで動作している Win32 ウィンドウのハンドルを指定して、<see cref="ExternalWindow"/> /// クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="hWnd">ウィンドウ ハンドル。</param> public ExternalWindow(IntPtr hWnd) { this.Handle = hWnd; if (_serviceInstance == null) { _serviceInstance = ServiceFactory.CreateInstance(); } this._external = _serviceInstance.Register(hWnd); this._external.StateChanged += this.ExternalOnStateChanged; this._external.SizeChanged += this.ExternalOnSizeChanged; this._external.WindowMoved += this.ExternalOnWindowMoved; this._external.Activated += this.ExternalOnActivated; this._external.Deactivated += this.ExternalOnDeactivated; this._external.Closed += this.ExternalOnClosed; this._rect = this.GetExtendFrameBounds(); this.IsActive = User32.GetForegroundWindow() == this.Handle; this.WindowState = WindowState.Normal; if (User32.IsIconic(hWnd)) this.WindowState = WindowState.Minimized; if (User32.IsZoomed(hWnd)) this.WindowState = WindowState.Maximized; }
private void ExternalOnClosed(IChromeHook sender) { this._external.Dispose(); this.Closed?.Invoke(this, EventArgs.Empty); }
private void ExternalOnDeactivated(IChromeHook sender) { this.IsActive = false; this.Deactivated?.Invoke(this, EventArgs.Empty); }
private void ExternalOnActivated(IChromeHook sender) { this.IsActive = true; this.Activated?.Invoke(this, EventArgs.Empty); }
private void ExternalOnWindowMoved(IChromeHook sender, Point newLocation) { this._rect = this.GetExtendFrameBounds(); this.LocationChanged?.Invoke(this, EventArgs.Empty); }
private void ExternalOnSizeChanged(IChromeHook sender, Size newSize) { this._rect = this.GetExtendFrameBounds(); this.SizeChanged?.Invoke(this, EventArgs.Empty); }
private void ExternalOnWindowMoved(IChromeHook sender, Point newLocation) { this.LocationChanged?.Invoke(this, EventArgs.Empty); }
private void ExternalOnSizeChanged(IChromeHook sender, Size newSize) { this.SizeChanged?.Invoke(this, EventArgs.Empty); }