mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
31 lines
1.0 KiB
C++
31 lines
1.0 KiB
C++
//=============================================================================//
|
|
//
|
|
// Purpose: Windows window procedure utilities
|
|
//
|
|
//=============================================================================//
|
|
#include "window.h"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: forces the window handle to the front
|
|
// Input : hwnd -
|
|
// Output : non-zero on success, null otherwise
|
|
//-----------------------------------------------------------------------------
|
|
BOOL ForceForegroundWindow(HWND hwnd)
|
|
{
|
|
BOOL ret = TRUE;
|
|
|
|
DWORD windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), LPDWORD(0));
|
|
DWORD currentThreadId = GetCurrentThreadId();
|
|
|
|
if (!AttachThreadInput(windowThreadProcessId, currentThreadId, true))
|
|
ret = FALSE;
|
|
if (!BringWindowToTop(hwnd))
|
|
ret = FALSE;
|
|
if (!ShowWindow(hwnd, SW_SHOW))
|
|
ret = FALSE;
|
|
if (!AttachThreadInput(windowThreadProcessId, currentThreadId, false))
|
|
ret = FALSE;
|
|
|
|
return ret;
|
|
}
|