I want my program to make the main form of another process have a minimum window size.
I have the correct window handle and tried setting the size of the window if it is smaller than my wanted size, but this way it is totally flashing.
MoveWindow() makes it flash too much, SetWindowPos() aswell
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace myProgram
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (var process in Process.GetProcessesByName("myTarget"))
{
var handle = process.MainWindowHandle; // gets all instances of the target game
// Something like SetWindowProperty(handle, MinimumSize, new Size(500, 500)) would be perfect
// or: setting the size with
// MoveWindow() - flashes horribly
// SetWindowPos() - flashes horribly aswell
// something else?
}
}
}
}
I would like a solution which is smoother and doesn't flash or look horrible.
The target program is a game, with a sizeable windows form.
– Rainmaker May 06 '17 at 05:52