Search:
 
Home
API / Change the Resolution of the Screen 05/01/2007

*!* Author: Alexandre Hédréville
*!* Changes the resolution of the screen
*!* Syntax: ChangeRes(tnWidth, tnHeight)
*!* return value: llRetVal
*!* Arguments: tnWidth, tnHeight
*!* tnWidth specifies width in pixels
*!* tnHeight specifies height in pixels

FUNCTION ChangeRes
LPARAMETERS tnWidth, tnHeight
LOCAL lnWidth, lnHeight, lnModeNum, lcDevMode

lnModeNum = 0
lcDevMode = REPLICATE(CHR(0), 156)
lnWidth = IIF(EMPTY(tnWidth), 800, tnWidth)
lnHeight = IIF(EMPTY(tnHeight), 600, tnHeight)

*!* Instrucciones DECLARE DLL para cambiar resolución
DECLARE INTEGER EnumDisplaySettings IN Win32API ;
STRING lpszDeviceName,;
INTEGER iModeNum, ;
STRING @lpDevMode

DECLARE INTEGER ChangeDisplaySettings IN Win32API STRING @lpDevMode, INTEGER dwFlags

*!* Bucle para obtener todos los modos disponibles
DO WHILE EnumDisplaySettings(NULL, lnModeNum, @lcDevMode) <> 0
lnModeNum = lnModeNum +1
ENDDO

*!* Configurar la structura DevMode
lcDevMode = STUFF(lcDevMode, 41, 4, LongToStr(1572864))
lcDevMode = STUFF(lcDevMode, 109, 4, LongToStr(tnWidth)) && Ancho
lcDevMode = STUFF(lcDevMode, 113, 4, LongToStr(tnHeight)) && Alto

*!* Cambiar resolucion
ChangeDisplaySettings(@lcDevMode, 1)
ENDFUNC

FUNCTION LongToStr
LPARAMETERS lnLongVal
LOCAL lnCnt, lcRetStr
lcRetStr = ''
FOR lnCnt = 24 TO 0 STEP -8
lcRetStr = CHR(INT(lnLongVal/(2^lnCnt))) + lcRetStr
lnLongVal = MOD(lnLongVal, (2^lnCnt))
NEXT
RETURN lcRetStr
ENDFUNC

Author:Alexandre Hédréville
Similar topics
API :
- Colors - Configurations of Windows
- Delete File
- Enable/Disable the Windows Start Button and TaskBa
- Hide and Unhide the Taskbar for Windows
- Move File
- Shutdown and Restart Windows
Documento sem título

Rafael Lippert
rafaellippert@gmail.com