When I exit from a game named MAFIA II, the screen looks like blended colors
mostly with pink and transparent glass. I can’t read anything on the screen. I
don’t have a graphics card. I have 2 GB of RAM, an Intel Pentium dual core
processor, I have 2.7 gHz. What is the problem and how can I solve it?
In this excerpt from
Answercast #47, I look at a case where a game is changing the display mode
on a computer and not reverting it on exit.
Become a Patron of Ask Leo! and go ad-free!
Graphics card
Well, I do beg to differ with you on at least one point. You absolutely
have a graphics card. It may not be a separate card, but you most definitely have a
graphics adapter of some sort. Otherwise, you wouldn’t have any screen at
all.
What usually happens in cases like this is that the game has set the
graphics card to a different video mode and then not restored that mode when it
exits.
Restore the video mode
The approach, if you can figure out enough of what you can see on the
screen:
-
You might try right-clicking on the desktop and hitting Screen
properties and then changing the resolution to something that you
know your system supports. -
Another approach might be to attach an external monitor to that machine and
see if that monitor handles whatever video mode the thing is left in.
But, ultimately, what it boils down to is that, like I said:
-
The game has changed the video mode to be something that it needs;
-
And it did not restore the video mode when it finished;
-
And Windows wasn’t made aware of that;
-
So Windows doesn’t know what to do or doesn’t think that anything has
changed and continues to treat the display as if it’s in the original mode,
not the mode that the game left it in.
You might want to check with the game’s manufacturer to see if they have a
specific fix for this problem.
Next from Answercast 47 – Why am I not getting some emails after my account has been hacked?
I had the same problem with one of my games, so I looked around in Google for something to help and I found a small program for this called “Iconoid”. You can set it up to resize your screen back to the original settings easily, along with a few other features. So far it has worked fine for me. Go to:
http://www.sillysot.com/
I’ve never really used it, but compatibility mode lets you tell Windows to run the program in 256 colors, 640 x 480 resolution. It sounds to me like the program is switching to those settings.
If it is, wouldn’t turning on compatibility mode on the games shortcut have Windows control switching the settings before it starts and restoring after it ends, rather than expecting a game (which was likely created a number of years ago) to be doing that?
Although I’ve never used it, Windows has compatibility mode which allows you to select certain screen settings.
I would expect that by telling Windows to change the screen settings that Windows would revert back to the usual settings when the game is done, rather than expecting the game to do it for you.
After reading your article I wote a Word macro that does the job. It works from Excell as well.
Copy/Paste the code in Notepad and save the file as mdlScreenResolution.bas .
Start MSWord.
Click the Office-button.
Close the new file you just started.
Start the Visual Basic editor (press Alt-F11).
Import mdlScreenResolution.bas (right-click on the Normal project and choose import)
Save Normal.dot (Contr-s)
Go back to the Word screen (click the blue “W” icon in the top left corner).
Click the Office-button again.
Choose Word options > Customize
and click the customize button next to Keyboard Shortcuts (so you have two times customize).
In the categories section (upper-left) scroll completely down and click Macro’s.
In the Macro’s section click Resolution
In the press new shortcut key box press a shortcut to your liking (I chose Contr-Shift-Y because it was not yet taken, but you can choose another one, you don’t use yet).
Go back to the Visual Basic editor and save Normal.dot again.
You may exit Word.
Now find a shortcut to Word anywhere an right-click it. Choose properties. In the Shortcut key section choose a shortcut (e.g. Contr-Alt-Shift-W) and click OK.
Test the macro: Start Word (Contr-Alt-Shift-W)
Run the macro (Contr-Shift-Y)
Change the screen resolution.
Run the macro again. You get your original resolution back. You need those shortcuts, because you do it blind after playing the game.
Here is the code:
‘ Found info on: http://www.ozgrid.com/forum/showthread.php?t=19051
‘ Thanks to the contributors.
Private Const sPath$ = “C:\”
Private Const sFileName$ = “ScreenResolution.tvi”
Private Declare Function GetSystemMetrics32 Lib “user32” Alias “GetSystemMetrics” _
(ByVal nIndex As Long) As Long
Private Declare Function GetSystemMetrics16 Lib “user” Alias “GetSystemMetrics” _
(ByVal nIndex As Integer) As Integer
Private Const SM_CXSCREEN = 0
Private Const SM_CYSCREEN = 1
Dim bWindowsNT As Boolean
Const VER_PLATFORM_WIN32s = 0
Const VER_PLATFORM_WIN32_WINDOWS = 1
Const VER_PLATFORM_WIN32_NT = 2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib “kernel32” Alias “GetVersionExA” (lpVersionInformation As OSVERSIONINFO) As Long
Const EWX_REBOOT = 2
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const CDS_UPDATEREGISTRY = &H1
Const CDS_FULLSCREEN = &H4
Const DISP_CHANGE_SUCCESSFUL = 0
Const DISP_CHANGE_RESTART = 1
Const HWND_BROADCAST = &HFFFF&
Const WM_DISPLAYCHANGE = &H7E&
Const SPI_SETNONCLIENTMETRICS = 42
Private Type DEVMODE
dmDeviceName As String * CCDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Declare Function EnumDisplaySettings Lib “user32” Alias “EnumDisplaySettingsA” (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Private Declare Function ChangeDisplaySettings Lib “user32” Alias “ChangeDisplaySettingsA” (lpDevMode As Any, ByVal dwFlags As Long) As Long
Private Declare Function ExitWindowsEx Lib “user32” (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Type LUID
lowpart As Long
highpart As Long
End Type
Private Type LUID_AND_ATTRIBUTES
pLuid As LUID
Attributes As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
Privileges As LUID_AND_ATTRIBUTES
End Type
Sub Resolution()
SaveVideoInfo
ChangeScreenResolution
End Sub
Sub SaveVideoInfo()
If Dir(sPath & sFileName) = “” Then
Dim vidWidth As Integer, vidHeight As Integer
If Left(Application.Version, 1) = 5 Then
vidWidth = GetSystemMetrics16(SM_CXSCREEN)
vidHeight = GetSystemMetrics16(SM_CYSCREEN)
Else
vidWidth = GetSystemMetrics32(SM_CXSCREEN)
vidHeight = GetSystemMetrics32(SM_CYSCREEN)
End If
Open sPath & sFileName For Output As 2
Print #2, vidWidth & “,” & vidHeight
Close 2
End If
End Sub
Private Sub ChangeScreenResolution()
Dim vidWidth As Integer, vidHeight As Integer
If Left(Application.Version, 1) = 5 Then
vidWidth = GetSystemMetrics16(SM_CXSCREEN)
vidHeight = GetSystemMetrics16(SM_CYSCREEN)
Else
vidWidth = GetSystemMetrics32(SM_CXSCREEN)
vidHeight = GetSystemMetrics32(SM_CYSCREEN)
End If
If Dir(sPath & sFileName) = “” Then
Exit Sub
End If
Dim DevM As DEVMODE
Dim lResult As Long
Dim iAns As Integer
Dim OSInfo As OSVERSIONINFO
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
Call GetVersionEx(OSInfo)
bWindowsNT = (OSInfo.dwPlatformId = VER_PLATFORM_WIN32_NT)
lResult = EnumDisplaySettings(0, 0, DevM)
Open (sPath & sFileName) For Input As 1
With DevM
.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
Input #1, .dmPelsWidth, .dmPelsHeight
If .dmPelsWidth = vidWidth And vidHeight = .dmPelsHeight Then
Exit Sub
End If
End With
lResult = ChangeDisplaySettings(DevM, CDS_FULLSCREEN)
Select Case lResult
Case DISP_CHANGE_RESTART
ExitWindowsEx EWX_REBOOT, 0
Case DISP_CHANGE_SUCCESSFUL
ChangeDisplaySettings DevM, CDS_UPDATEREGISTRY
SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, SPI_SETNONCLIENTMETRICS, ByVal 0&
Case Else
End Select
End Sub