0
我非常努力地找到一种方法来提出另一个程序窗口。如何将不属于该程序的另一个窗口向前推进
例如,我使用FindWindow来查找记事本的句柄。然后我尝试使用SetWindowPos(hWnd,0,0,0,0,0,SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE)使窗口前进;
但它只是不工作! ShowWindow也没有!
你可以请帮忙,也许让我看一段代码?
感谢
我非常努力地找到一种方法来提出另一个程序窗口。如何将不属于该程序的另一个窗口向前推进
例如,我使用FindWindow来查找记事本的句柄。然后我尝试使用SetWindowPos(hWnd,0,0,0,0,0,SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE)使窗口前进;
但它只是不工作! ShowWindow也没有!
你可以请帮忙,也许让我看一段代码?
感谢
说不上来,如果这是同样的事情或没有,但在开发Windows某些时候微软增加了一些太聪明,通过半“反弹出”代码,将阻止一个程序,不重点是从最小化它的窗口...而是,窗口在程序栏中的入口只会闪烁。也许有类似的逻辑阻止非前景节目向前发展?
在任何情况下,这里是一些代码来试试,可能会或可能不会帮助:
// Check to see if we are the foreground thread
DWORD foregroundThreadID = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
DWORD ourThreadID = GetCurrentThreadId();
// If not, attach our thread's 'input' to the foreground thread's
if (foregroundThreadID != ourThreadID) AttachThreadInput(foregroundThreadID, ourThreadID, TRUE);
// Bring our window to the foreground
SetForegroundWindow(hWnd);
// If we attached our thread, detach it now
if (foregroundThreadID != ourThreadID) AttachThreadInput(foregroundThreadID, ourThreadID, FALSE);
// Force our window to redraw
InvalidateRect(hWnd, NULL, TRUE);
嗯,你不必为MSFT的制止了“推窗力度不够升值在用户的脸上“的态度。真丢脸。 – 2010-10-07 23:51:23
我对此有很多赞赏。我只是觉得他们应该将SetForegroundWindow()函数重命名为SetForegroundWindowButNotUnlessIAddSomeExtraMumboJumboToShowThatIReallyMeanIt(),这样它的名字才能准确地反映它的行为。 – 2010-10-08 01:55:06