// 发现那个传说中的 SwitchToThisWindow(Handle,true); 不是那么好用。
{// 这是切换别的窗口到前台
HWND h1 = FindWindow("Notepad", NULL);
DWORD t1 = GetWindowThreadProcessId(h1, NULL);
DWORD t2 = GetCurrentThreadId();
if(t1 != t2)
{
AttachThreadInput(t1, t2, true);
BringWindowToTop(h1);
ShowWindow(h1,SW_SHOW);
AttachThreadInput(t1, t2, false);
}
else
{
BringWindowToTop(h1);
}
}
{// 这是切换自己到前台
HWND h1 = GetForegroundWindow();
DWORD t1 = GetWindowThreadProcessId(h1, NULL);
DWORD t2 = GetCurrentThreadId();
if(t1 != t2)
{
AttachThreadInput(t1, t2, true);
BringWindowToTop(Application->Handle);
ShowWindow(Application->Handle,SW_SHOW);
AttachThreadInput(t1, t2, false);
}
else
{
BringWindowToTop(h1);
}
}
// 一会些个通用点的。
{// 这是切换别的窗口到前台
HWND h1 = FindWindow("Notepad", NULL);
DWORD t1 = GetWindowThreadProcessId(h1, NULL);
DWORD t2 = GetCurrentThreadId();
if(t1 != t2)
{
AttachThreadInput(t1, t2, true);
BringWindowToTop(h1);
ShowWindow(h1,SW_SHOW);
AttachThreadInput(t1, t2, false);
}
else
{
BringWindowToTop(h1);
}
}
{// 这是切换自己到前台
HWND h1 = GetForegroundWindow();
DWORD t1 = GetWindowThreadProcessId(h1, NULL);
DWORD t2 = GetCurrentThreadId();
if(t1 != t2)
{
AttachThreadInput(t1, t2, true);
BringWindowToTop(Application->Handle);
ShowWindow(Application->Handle,SW_SHOW);
AttachThreadInput(t1, t2, false);
}
else
{
BringWindowToTop(h1);
}
}
// 一会些个通用点的。