Change Display Settings on the Fly

When writing a game for Windows 95, set the display resolution to 640-by-480, set the color palette to True Color when it runs, and restore it to its initial mode when it ends. Use this function to implement it:

 '- DeclaresPrivate Declare Function lstrcpy _	Lib "kernel32" Alias "lstrcpyA" _	(lpString1 As Any, lpString2 As Any) _	As LongConst CCHDEVICENAME = 32Const CCHFORMNAME = 32Private Type DEVMODE	dmDeviceName As String * CCHDEVICENAME	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 * CCHFORMNAME	dmUnusedPadding As Integer	dmBitsPerPel As Integer	dmPelsWidth As Long	dmPelsHeight As Long	dmDisplayFlags As Long	dmDisplayFrequency As LongEnd TypePrivate Declare Function _	ChangeDisplaySettings Lib _	"User32" Alias "ChangeDisplaySettingsA" (_	ByVal lpDevMode As Long, _	ByVal dwflags As Long) As Long'- code' Here is the function that sets the display ' mode. Width is the width of screen, Height ' is the height of screen, Color is the number ' of bits per pixel. Set the Color value to -1 ' if you only want to change the screen ' resolution.Public Function SetDisplayMode(Width As _	Integer,Height As Integer, Color As _	Integer) As LongConst DM_PELSWIDTH = &H80000Const DM_PELSHEIGHT = &H100000Const DM_BITSPERPEL = &H40000Dim NewDevMode As DEVMODEDim pDevmode As LongWith NewDevMode	.dmSize = 122	If Color = -1 Then		.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT	Else		.dmFields = DM_PELSWIDTH Or _			DM_PELSHEIGHT Or DM_BITSPERPEL	End If	.dmPelsWidth = Width	.dmPelsHeight = Height	If Color <> -1 Then		.dmBitsPerPel = Color	End IfEnd WithpDevmode = lstrcpy(NewDevMode, NewDevMode)SetDisplayMode = ChangeDisplaySettings(pDevmode, 0)End Function

You can change the display mode easily with this function. For example, write this code that changes the resolution to 640-by-480 and the color palette to 24-bit True Color:

 i = SetDisplayMode(640, 480, 24)

If the function is successful, it returns zero.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

Top 5 B2B SaaS Marketing Agencies for 2023

In recent years, the software-as-a-service (SaaS) sector has experienced exponential growth as more and more companies choose cloud-based solutions. Any SaaS company hoping to stay ahead of the curve in this quickly changing industry needs to invest in effective marketing. So selecting the best marketing agency can mean the difference

technology leadership

Why the World Needs More Technology Leadership

As a fact, technology has touched every single aspect of our lives. And there are some technology giants in today’s world which have been frequently opined to have a strong influence on recent overall technological influence. Moreover, those tech giants have popular technology leaders leading the companies toward achieving greatness.

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.