/// <summary> /// Moves the form to match the size and location of the selected process window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSnap_Click(object sender, EventArgs e) { Text = cbProcessDropDown.SelectedItem.ToString(); // Check each process to see if it matches the selected dropdown item Process procToChange = new Process(); foreach (Process proc in _processWindowList) { if (proc.MainWindowTitle.Equals(cbProcessDropDown.SelectedItem.ToString())) { procToChange = proc; } } ImportFunctions.RECT newWindowRect = new ImportFunctions.RECT(); ImportFunctions.GetWindowRect(procToChange.MainWindowHandle, ref newWindowRect); Location = new System.Drawing.Point(newWindowRect.Left, newWindowRect.Top); Size = new System.Drawing.Size(newWindowRect.Right - newWindowRect.Left, newWindowRect.Bottom - newWindowRect.Top); }
/// <summary> /// Moves the selected process window to match the size and shape of the form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnApplyButton_Click(object sender, EventArgs e) { Text = cbProcessDropDown.SelectedItem.ToString(); Process procToChange = new Process(); foreach (Process proc in _processWindowList) { if (proc.MainWindowTitle.Equals(cbProcessDropDown.SelectedItem.ToString())) { procToChange = proc; break; } } ImportFunctions.MoveWindow(procToChange.MainWindowHandle, Convert.ToInt32(txtPosX.Text), Convert.ToInt32(txtPosY.Text), Convert.ToInt32(txtWidth.Text), Convert.ToInt32(txtHeight.Text), false); }