Thanks for that link. The information there confirms what i was thinking on where to look.
I managed to kind of reach my goal, but am far from pleased with the results.
I will share with you my results.
Note: All the following information has been tested with windowed mode. This can be achieved by having the -windowed argument in the gta4.exe launch path.
Code:
//The following hooks the windowmessages. Whenever things happen in a window, the window will send messages to this function.
WNDPROC g_gameWndProc;
g_gameWndProc = ( WNDPROC )SetWindowLongA( GAME_HWND, GWL_WNDPROC, ( LONG )WindowProc );
//The following line will unhook the windowproc(), it should go into your unhook function.
SetWindowLongA( GAME_HWND, GWL_WNDPROC, ( LONG )g_gameWndProc );
//Now in our hooked function we check for the message WM_NCACTIVATE and block it.
//You will see I will pass WM_KILLFOCUS, but you could just have returned NULL for the same result.
LRESULT CALLBACK WindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam )
{
if(Msg == WM_NCACTIVATE && wParam == 0)
{
Log->Write("WM_NCACTIVATE for hWnd %i wParam %i lParam %i", hWnd, wParam, lParam);
return CallWindowProc( g_gameWndProc, hWnd, WM_KILLFOCUS, wParam, lParam );
}
return CallWindowProc( g_gameWndProc, hWnd, Msg, wParam, lParam );
}
After doing that, congratulations, after ALT+TAB the window stays active.
Tho there is one problem, the window holds the mouse focus and you cannot leave.
I did found the following workaround:
-If you want to keep the game running and want full interaction with another window (like your webbrowser) you should minimize GTA4 with the use of shortcut "WINDOWS KEY + KEY DOWN".
-Then it will minimize into your taskbar.
-Click GTA4 in your taskbar to show the window. The GTA4 window now has focus
-Now ALT+TAB and perform a mouseclick.
You now have GTA4 running while not interacting with the window.