2017-05-06 73 views
0

我想要我的程序使主窗体的另一个进程有一个最小的窗口大小。是否可以设置另一个进程窗体的MinimumSize属性? C#

我有正确的窗口句柄,并尝试设置窗口的大小,如果它小于我想要的大小, 但这种方式它是完全闪烁。

的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? 
     } 
    } 
    } 
} 

我想一个解决方案,它是光滑,不闪烁或看可怕。

目标程序是一个游戏,具有相当大的窗口形式。

+0

看来你的问题对我来说还不清楚。你有什么样的地方可以参考你需要的吗? – Muj

+0

您可能需要实现全局系统钩子,截取并修改'WM_GETMINMAXINFO'中的'lParam'。我不认为这在C#中是可能的。 – bansi

+0

请参阅此[Win32 GUI闪烁调整大小](http://stackoverflow.com/questions/2036599/win32-gui-flickering-on-resize)问题。
Rainmaker

回答

0

您正在寻找MoveWindow。看起来像:

[DllImport("user32.dll", SetLastError = true)] 
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool rePaint); 

其中hWnd是要调整大小的应用程序。

+0

使用这将使我的目标闪光灯,这是我不想要的。 – TheElderScroller

相关问题