在.NET中使进程窗口可见/不可见
我有我的申请,我正在其中开始一个新的流程。但我需要在此过程中调整窗口大小以满足我的要求。但首先该过程以正常大小打开窗口,然后我调整其大小以适应。这让它看起来很奇怪。那么我可以在不可见模式下使用 winodw 启动该过程,然后调整大小并使其可见吗?
ProcessStartInfo startInfo = new ProcessStartInfo("myApp.exe");
MyApp = Process.Start(startInfo);
Thread.Sleep(2000);
MoveWindow(MyApp.MainWindowHandle, 0, 380, 2040, 1150, true);
I have my application, in which I am starting a new process. But I need to resize the window in the process to fit into my requirement. But first the process opens the window in normal size and then I resize it to fit. This make it look odd. So can I start the process with the winodw in invisible mode and then resize and then make it visible?
ProcessStartInfo startInfo = new ProcessStartInfo("myApp.exe");
MyApp = Process.Start(startInfo);
Thread.Sleep(2000);
MoveWindow(MyApp.MainWindowHandle, 0, 380, 2040, 1150, true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 .Start() 调用之前尝试过
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
来隐藏它?然后用你的代码来显示它?像这样:
要显示窗口,请导入此方法:
然后在 MoveWindow 函数之后调用它:
Tried
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
before .Start() call to hide it? And then use your code to show it?Like this:
To show the window import this method:
Then call it after MoveWindow function:
根据 http://msdn.microsoft.com /en-us/library/ms633548%28v=vs.85%29.aspx 您应该对不属于您的 Windows 使用 ShowWindowAsync 以避免不稳定 结果。
According to http://msdn.microsoft.com/en-us/library/ms633548%28v=vs.85%29.aspx you should use ShowWindowAsync for Windows you don't own to avoid erratic results.
考虑到您正在使用正在加载进程的面板。
你可以使用这行代码
considering that you are using a panel where your process is loading..
you can use this line of code