::SetWindowPos(ydh_hwnd[T_hwnd],HWND_BOTTOM,0,0,0,0,SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
::SetWindowPos(ydh_hwnd[T_hwnd],HWND_TOP,400,150,600,500,SWP_SHOWWINDOW );
//这两个一起使用也不行. ::SetForegroundWindow(ydh_hwnd[T_hwnd]);
::BringWindowToTop(ydh_hwnd[T_hwnd]);
::SetFocus(ydh_hwnd[T_hwnd]);
::SendMessage(ydh_hwnd[T_hwnd],WM_SHOWWINDOW,0,0); ydh_hwnd 数组,保存了当前所有应用程序的句柄, 以上方法都用过了. 有部分可以成功切换. 有部分不行(窗口显示不出来,但是被窗口激活了的) , 然后我点击windows"开始"的任务栏 来切换窗口 都可以顺利切换(请问是windows是用什么语句呢,为什么这么有效) . 奇怪的是用"开始"的任务栏切换过的窗口, 又可以用我的程序来顺利切换了.
::SetWindowPos(ydh_hwnd[T_hwnd],HWND_TOP,400,150,600,500,SWP_SHOWWINDOW );
//这两个一起使用也不行. ::SetForegroundWindow(ydh_hwnd[T_hwnd]);
::BringWindowToTop(ydh_hwnd[T_hwnd]);
::SetFocus(ydh_hwnd[T_hwnd]);
::SendMessage(ydh_hwnd[T_hwnd],WM_SHOWWINDOW,0,0); ydh_hwnd 数组,保存了当前所有应用程序的句柄, 以上方法都用过了. 有部分可以成功切换. 有部分不行(窗口显示不出来,但是被窗口激活了的) , 然后我点击windows"开始"的任务栏 来切换窗口 都可以顺利切换(请问是windows是用什么语句呢,为什么这么有效) . 奇怪的是用"开始"的任务栏切换过的窗口, 又可以用我的程序来顺利切换了.
Starting with Microsoft Windows 98 and Windows 2000, the system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
Windows 2000/XP: No menus are active.
试试LockSetForegroundWindow()看
::ShowWindow(ydh_hwnd[T_hwnd],SW_SHOWNORMAL);