MFC定位窗口焦点
程序员文章站
2024-02-10 22:07:10
...
// 把焦点定位到桌面端主界面
{
HWND hMainWnd = NULL;
CLib_Global::GetAPI().pITools->GetWindowHandle(hMainWnd);
FALSE_RETURN(NULL!=hMainWnd);
CWnd *pWnd = CWnd::FromHandle(hMainWnd);
if (pWnd != NULL && pWnd->GetParent() != NULL)
{
CDC dc;
dc.Attach(::GetWindowDC(pWnd->GetParent()->GetSafeHwnd()));
dc.GetWindow()->SetActiveWindow();
}
else
{
CDC dc;
dc.Attach(::GetWindowDC(hMainWnd));
dc.GetWindow()->SetActiveWindow();
}
}