c++windowsトップフォーム究極のシナリオ


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;
}