c++ windows置顶窗体终极方案

作者: admin 分类: C++ 发布时间: 2020-08-01 21:20

windows置顶窗体终极方案

LRESULT OnForceShow(HWND hWnd)

{

HWND hForeWnd = NULL; 

DWORD dwForeID = 0; 

DWORD dwCurID = 0; 

 

hForeWnd =  ::GetForegroundWindow(); 

dwCurID = :: GetCurrentThreadId(); 

dwForeID =  ::GetWindowThreadProcessId( hForeWnd, NULL ); 

::AttachThreadInput( dwCurID, dwForeID, TRUE); 

::ShowWindow( hWnd, SW_SHOWNORMAL ); 

::SetWindowPos( hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE ); 

::SetWindowPos( hWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE ); 

::SetForegroundWindow( hWnd ); 

::AttachThreadInput( dwCurID, dwForeID, FALSE);

 

return S_OK;

}

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

标签云