在最顶层创建一个流程窗口 [英] create a process window on topmost
问题描述
在我的主应用程序中,我调用一个名为A的进程。这个进程正在调用另一个应用程序B.问题是,进程A始终位于我的主窗口顶部,但是当进程B启动时它位于我的主要后面window.It不是每次我都在进行操作,但有时候。
调用应用程序A后,我已申请等待退出然后我正在制作窗口线程要睡觉(这在我的情况下是必需的),同时应用程序B由A.启动。这个B进程窗口有时在主窗口后面。
任何人都可以建议我做任何事情吗?
In my main application,I'mm calling a process named A.This process is calling another application B.Problem is,the process A is always top on my main window,but when process B starts it is situated behind my main window.It is occurring not every time I am doing the operation,but sometime.
After calling application A,I have applied wait for exit and then I am making main window thread to sleep(this is required in my case),in the mean time application B is started by A.This B process window sometime is behind the main window.
can any one suggest me to do anything?
推荐答案
请注意,这是MSDN的解决方案的副本,您的特定情况可能不需要cx和cy ...
如果windows表格请试试这个:
处理流程= Process.Start(psi) ;
IntPtr windowHandle = process.MainWindowHandle;
RECT r;
GetWindowR ect(new HandleRef(this,windowHandle),out r);
int cx = r.Right - r.Left;
int cy = r.Bottom - r.Top;
cx - = 20;
cy - = 20;
SetWindowPos(windowHandle,(IntPtr)SpecialWindowHandles.HWND_TOPMOST,r.Left,r.Top,cx,cy,SetWindowPosFlags.SWP_SHOWWINDOW);
如果这有帮助,请花时间接受解决方案。
Note that this is a copy of a solution from MSDN, cx and cy may not be needed for your particular case...
Try this if windows forms:
Process process = Process.Start(psi);
IntPtr windowHandle = process.MainWindowHandle;
RECT r;
GetWindowRect(new HandleRef(this, windowHandle), out r);
int cx = r.Right - r.Left;
int cy = r.Bottom - r.Top;
cx -= 20;
cy -= 20;
SetWindowPos(windowHandle, (IntPtr) SpecialWindowHandles.HWND_TOPMOST, r.Left, r.Top, cx, cy, SetWindowPosFlags.SWP_SHOWWINDOW);
If this helps, please take time to accept the solution.
这篇关于在最顶层创建一个流程窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!