mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add 'ForceForegroundWindow' windows utility
Forces the window handle to be on top.
This commit is contained in:
parent
5c05f91891
commit
c059ec65ac
30
r5dev/windows/window.cpp
Normal file
30
r5dev/windows/window.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//=============================================================================//
|
||||
//
|
||||
// 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;
|
||||
}
|
3
r5dev/windows/window.h
Normal file
3
r5dev/windows/window.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
BOOL ForceForegroundWindow(HWND hwnd);
|
Loading…
x
Reference in New Issue
Block a user