BringWindowToTop完美激活窗口与置顶

时间:2023-03-08 17:41:58
BringWindowToTop完美激活窗口与置顶
        void ActiveWin(IntPtr h)
{
IntPtr hForeWnd = GetForegroundWindow();//获取当前窗口句柄
int tIdCur = GetWindowThreadProcessId(hForeWnd, IntPtr.Zero);//获取当前窗口句柄的线程ID
int tIdCurProgram = GetCurrentThreadId();//获取当前运行程序线程ID
var r = AttachThreadInput(tIdCur, tIdCurProgram, );//是否能成功和当前自身进程所附加的输入上下文有关
//SwitchToThisWindow(h, true);
//ShowWindow(hJD, 9);
BringWindowToTop(h);
//SetForegroundWindow(h);
//SetActiveWindow(hJD);
//SetFocus(hJD);
AttachThreadInput(tIdCur, tIdCurProgram, );
}
        void TopWin(IntPtr h)
{
SetWindowPos(h, -, , , , , | | | );
}