private void windowDragHere_MouseMove(object sender, MouseEventArgs e) { if (!drag_here_mode_) { // drag_hereモードでなければ何もしない return; } Point screen_location = this.windowDragHere.PointToScreen(e.Location); UIntPtr next_window = ExternalAPI.WindowFromPoint(screen_location.X, screen_location.Y); if (next_window == UIntPtr.Zero) { // nop return; } if (current_window_ == UIntPtr.Zero) { // 初回実行: どうせDragHereボタンが取得されているはずなので、一回は無視 current_window_ = next_window; } if (next_window == current_window_) { // 対象ウィンドウが変わっていなければ何も描画する必要はない return; } // ウィンドウが異なる場合、描画していたウィンドウをアップデートして描画内容を消しておく ClearCurrentWindow(); // 現在処理中のウィンドウを更新 current_window_ = next_window; current_dc_ = ExternalAPI.GetDC(current_window_); current_graphics_ = System.Drawing.Graphics.FromHdc(current_dc_); // 描画 ExternalAPI.RECT current_rect; ExternalAPI.GetClientRect(current_window_, out current_rect); current_graphics_.DrawRectangle(orange_pen_, current_rect.left, current_rect.top, current_rect.right - current_rect.left, current_rect.bottom - current_rect.top); }
public void SetWindowFromPoint(int screen_x, int screen_y) { UIntPtr window = ExternalAPI.WindowFromPoint(screen_x, screen_y); ((viewmodel.LayoutParameter)layout_parameters_.Current).SetWindow(window); }