18
18
#include " Patches\InputTweaks.h"
19
19
20
20
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
21
+ void SetWindowToTop (HWND MainhWnd);
21
22
22
23
WNDPROC OriginalWndProc = nullptr ;
23
24
HWND DeviceWindow = nullptr ;
@@ -249,6 +250,9 @@ HRESULT m_IDirect3D8::CreateDevice(UINT Adapter, D3DDEVTYPE DeviceType, HWND hFo
249
250
// Update presentation parameters
250
251
UpdatePresentParameter (pPresentationParameters, hFocusWindow);
251
252
253
+ // Bring window to the forefront
254
+ SetWindowToTop (DeviceWindow);
255
+
252
256
// Get WndProc
253
257
if (HookWndProc && DeviceWindow && !OriginalWndProc)
254
258
{
@@ -495,18 +499,8 @@ void SetScreenAndWindowSize()
495
499
WindowInChange = false ;
496
500
}
497
501
498
- // Adjusting the window position for WindowMode
499
- void AdjustWindow (HWND MainhWnd, LONG displayWidth, LONG displayHeight)
502
+ void SetWindowToTop (HWND MainhWnd)
500
503
{
501
- if (!IsWindow (MainhWnd) || !displayWidth || !displayHeight)
502
- {
503
- LOG_LIMIT (100 , __FUNCTION__ << " Error: could not set window size, nullptr." );
504
- return ;
505
- }
506
-
507
- // Remember first run
508
- static bool FirstRun = true ;
509
-
510
504
// Set topmost
511
505
LONG lExStyle = GetWindowLong (MainhWnd, GWL_EXSTYLE);
512
506
SetWindowLong (MainhWnd, GWL_EXSTYLE, lExStyle | WS_EX_TOPMOST);
@@ -543,6 +537,22 @@ void AdjustWindow(HWND MainhWnd, LONG displayWidth, LONG displayHeight)
543
537
AttachThreadInput (currentThreadId, foregroundThreadId, FALSE );
544
538
}
545
539
}
540
+ }
541
+
542
+ // Adjusting the window position for WindowMode
543
+ void AdjustWindow (HWND MainhWnd, LONG displayWidth, LONG displayHeight)
544
+ {
545
+ if (!IsWindow (MainhWnd) || !displayWidth || !displayHeight)
546
+ {
547
+ LOG_LIMIT (100 , __FUNCTION__ << " Error: could not set window size, nullptr." );
548
+ return ;
549
+ }
550
+
551
+ // Remember first run
552
+ static bool FirstRun = true ;
553
+
554
+ // Bring window to the forefront
555
+ SetWindowToTop (MainhWnd);
546
556
547
557
// Get screen width and height
548
558
LONG screenWidth = 0 , screenHeight = 0 ;
@@ -560,7 +570,7 @@ void AdjustWindow(HWND MainhWnd, LONG displayWidth, LONG displayHeight)
560
570
561
571
// Get window style
562
572
LONG lStyle = GetWindowLong (MainhWnd, GWL_STYLE) | WS_VISIBLE;
563
- lExStyle = GetWindowLong (MainhWnd, GWL_EXSTYLE);
573
+ LONG lExStyle = GetWindowLong (MainhWnd, GWL_EXSTYLE);
564
574
565
575
// Get new style
566
576
LONG lNewStyle = (lStyle | WS_OVERLAPPEDWINDOW) & ~(WS_MAXIMIZEBOX | WS_THICKFRAME);
0 commit comments