1.我想找到一個窗口並將焦點設置在窗口上,但窗口沒有佔用焦點。找到一個窗口並設置它的焦點
2.如果我使用HWND_TOP,那麼它不會使窗口處於活動狀態,如果我使用HWND_TOPMOST,那麼它會使窗口始終處於頂部。
任何人都可以幫助我?
HWND hwndAppDlg = ::FindWindowEx(hwndDesktop,NULL,lpszClass,lpszWindow);
if(hwndAppDlg && IsWindow(hwndAppDlg))
{
CRect rcAppDlg;
if(0 == ::GetWindowRect(hwndAppDlg,rcAppDlg))
{
OutputDebugString(L"\n GetWindowRect failed...");
return FALSE;
}
if(0 == ::SetWindowPos(hwndAppDlg,HWND_TOPMOST,rcAppDlg.left,rcAppDlg.top,rcAppDlg.Width(),rcAppDlg.Height(),SWP_SHOWWINDOW))
{
OutputDebugString(L"\n SetWindowPos failed...");
return FALSE;
}
if(0 == ::PostMessage(hwndAppDlg,WM_SETFOCUS,0,0))
{
OutputDebugString(L"\n WM_SETFOCUS failed");
return FALSE;
}
return TRUE;
}
它甚至沒有激活對話框。 – Ashish 2010-01-18 13:56:52