【发布时间】:2017-05-06 03:42:27
【问题描述】:
我希望我的程序使另一个进程的主窗体具有最小窗口大小。
我有正确的窗口句柄并尝试设置窗口的大小,如果它小于我想要的大小, 但这样一来,它就完全闪烁了。
MoveWindow() 让它闪烁太多, SetWindowPos() 以及
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?
}
}
}
}
我想要一个更流畅、不闪现或看起来不可怕的解决方案。
目标程序是一个游戏,具有相当大的窗口形式。
【问题讨论】:
-
看来你的问题我不清楚。你有什么样品可以参考你需要的吗?
-
您可能需要实现全局系统钩子,拦截并修改
lParam中的WM_GETMINMAXINFO。我认为这仅在 C# 中是不可能的。