LordWolfy
asked on
Directx Alt-Tab Not Restoring Desktop in Native Resoultion
Greetings,
I have a directx game app which runs perfectly in any resolution, full screen or windowed and has no problems with alt-tab except when using full screen with the same resolution as the desktop.
In this case, the desktop or app being switched to is not displayed. The screen dosent get updated at all except for the mouse pointer which appears normal for whatever's supposed to be there (ie. will react to window controls such as text, links etc). All input appears to work correctly and the app can even be alt-tabbed back into again and continue.
If the resolution is different from that of the desktop then everthing works perfectly.
I'm using a standard message loop. Here is an extract of the relevant code (it's in Delphi but I'm sure the structure will be plain enough to see). Some code and variables have been stripped out to make it more readable:
I have a directx game app which runs perfectly in any resolution, full screen or windowed and has no problems with alt-tab except when using full screen with the same resolution as the desktop.
In this case, the desktop or app being switched to is not displayed. The screen dosent get updated at all except for the mouse pointer which appears normal for whatever's supposed to be there (ie. will react to window controls such as text, links etc). All input appears to work correctly and the app can even be alt-tabbed back into again and continue.
If the resolution is different from that of the desktop then everthing works perfectly.
I'm using a standard message loop. Here is an extract of the relevant code (it's in Delphi but I'm sure the structure will be plain enough to see). Some code and variables have been stripped out to make it more readable:
Function WindowProc (AHWnd, AMsg, AWParam, ALParam : Integer) : Integer; StdCall;
Begin
If AMsg = WM_DESTROY Then
PostQuitMessage (0);
If AMsg = WM_ACTIVATEAPP Then
WindowActive := (AWParam <> 0);
Result := DefWindowProc (AHWnd, AMsg, AWParam, ALParam);
End;
Function CreateMainWindow (HInst : HWnd) : HWnd;
Var
WinHandle : HWnd;
WinWidth, WinHeight : LongInt;
Begin
WinClass.lpszClassName:= 'MainWindow';
WinClass.lpfnWndProc := @WindowProc;
WinClass.hInstance := HInst;
WinClass.hbrBackground:= 8;
WinClass.hIcon := LoadIcon (HInst, 'MAINICON');
WinClass.hCursor := LoadCursor (0, IDC_ARROW);
RegisterClass(WinClass);
WinWidth := WW_EngineSettings.DisplayWidth + 6;
WinHeight := WW_EngineSettings.DisplayHeight + 25;
WinHandle := CreateWindow (WinClass.lpszClassName,'Main Window',
(WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or WS_VISIBLE),
0, 0, WinWidth, WinHeight, 0, 0, HInst, NIL);
Result := WinHandle;
End;
Begin
MainWindowHandle := CreateMainWindow (hInstance);
If MainWindowHandle = 0 Then
Exit;
If Not (WW_EngineSettings.DisplayWindowed) Then
ShowCursor (False);
PeekMessage (WinMsg, 0, 0, 0, PM_NOREMOVE);
While WinMsg.Message <> WM_QUIT Do
Begin
If PeekMessage (WinMsg, 0, 0, 0, PM_REMOVE) Then
Begin
TranslateMessage (WinMsg);
DispatchMessage (WinMsg);
End;
If WindowActive Then
// App main called from here
Else
WaitMessage;
CurrentTime := timeGetTime;
End;
If Not (WW_EngineSettings.DisplayWindowed) Then
ShowCursor (True);
DestroyWindow (MainWindowHandle);
End.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.