by horacio » Mon Oct 27, 2008 2:58 pm
jaba;
Disculpame que no te respondí en tiempo y forma pero tuve algunos inconvenientes con mi proveedor de internet. Aqui te mando el código
#define DM_PELSWIDTH nHex("80000")
#define DM_PELSHEIGHT nHex("100000")
Function CambiaResolucion( nAncho, nAlto, lPreguntar)
Local oDevMode
Local lPosible
Local cBuffer
Local lCamReso := .f.
Default nAncho := GetSysMetrics( 0 ), nAlto := GetSysMetrics( 1 ), lPreguntar := .t.
Struct oDevMode
Member cDevName AS STRING LEN 32
Member nSpecVer AS WORD
Member nDrvVer AS WORD
Member nSize AS WORD
Member nDrvExtra AS WORD
Member nFields AS DWORD
Member nOrientat AS WORD
Member nPaperSiz AS WORD
Member nPaperLen AS WORD
Member nPaperWid AS WORD
Member nScale AS WORD
Member nCopies AS WORD
Member nDefSrc AS WORD
Member nPrnQlty AS WORD
Member nColor AS WORD
Member nDuplex AS WORD
Member nYResolut AS WORD
Member nTTOpt AS WORD
Member nCollate AS WORD
Member cFormName AS STRING LEN 32
Member nUnusePad AS WORD
Member nBitsPPel AS DWORD
Member nPelWidth AS DWORD
Member nPelHeigh AS DWORD
Member nDisFlags AS DWORD
Member nDisFreq AS DWORD
Endstruct
cBuffer := oDevMode : cBuffer
// Comprueba si es posible cambiar la resolución
lPosible := EnumDisplaySettings(0, 0, @cBuffer)
// Si es posible cambiar la resolución
If( lPosible )
If( lPreguntar )
If( !MsgYesNo("Desea cambiar la resolución?", "Atención") )
Return lCamReso
end
end
oDevMode:nFields := nOr( DM_PELSWIDTH, DM_PELSHEIGHT )
oDevMode:nPelWidth := nAncho
oDevMode:nPelHeigh := nAlto
cBuffer:=oDevMode:cBuffer
Try
ChangeDisplaySettings(@cBuffer, 4)
lCamReso := .T.
Catch
MsgStop("Modo no soportado", "Error" )
End
else
MsgStop("Modo no soportado", "Error" )
end
Return lCamReso
DLL32 FUNCTION EnumDisplaySettings(lpszDeviceName AS DWORD,;
iModeNum AS DWORD, ;
@lpDevMode AS LPSTR) AS BOOL PASCAL;
FROM "EnumDisplaySettingsA" LIB "User32.dll"
DLL32 FUNCTION ChangeDisplaySettings(@lpDevMode AS LPSTR,;
dwFlags AS DWORD) AS DWORD;
FROM "ChangeDisplaySettingsA" LIB "User32.dll"
DLL32 FUNCTION ExitWindowsEx(uFlags AS DWORD,;
dwReserved AS DWORD) AS DWORD PASCAL;
LIB "user32.dll"
Probé tu solución y funciona perfectamente
Saludos