FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Change/save Screen-resolution to Applic.-resol. at Runtime ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Change/save Screen-resolution to Applic.-resol. at Runtime ?

Posted: Wed Mar 30, 2011 07:09 PM
Hello,

I found some API-functions to make it possible, to adjust the Screen-resolution
to Application-resolution.
Does it make sense, to adjust it at Prog-start and restore the original Resolution at Prog.-end ?
I don't know, if it is possible, to change the Resolution in silent-mode.
Maybe somebody found a working Solution ?

// get existing Resolution
Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" _
(ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lptypDevMode As Any) As Boolean

// Change Resolution
Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" _
(lptypDevMode As Any, ByVal dwFlags As Long) As Long


// Exit Windows
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved _
As Long) As Long

Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Wed Mar 30, 2011 10:34 PM
Uwe,

I think that this code does what you need...

Code (fw): Select all Collapse
CamReso ( 1024, 768, .f. )


Code (fw): Select all Collapse
///////////////////////////////////////////////////////////////////
/// FUNCION CamReso
/// CAMBIA RESOLUCION DE PANTALLA TEMPORALMENTE
/// Manuel Valdenebro 2008
/// Adaptaci贸n ChangeRes() Marcelo Gomes/Yuri Marcelino
/// <!-- m --><a class="postlink" href="http://www.fivewin.com.br/forum/topic.asp?TOPIC_ID=10465">http://www.fivewin.com.br/forum/topic.a ... C_ID=10465</a><!-- m -->
/// ---------------------------------------
// nAncho ancho pantalla
// nAlto alto pantalla
// lPreguntar si pregunta antes de realizar el cambio
///////////////////////////////////////////////////////////////////

#Include "dll.ch"
#Include "Struct.ch"

Function CamReso(nAncho, nAlto, lPreguntar)
Local DM_PELSWIDTH := nHex("80000")
Local DM_PELSHEIGHT := nHex("100000")
Local oDevMode
Local lPosible
Local cBuffer
Local lCamReso := .f.
*DEFAULT lPreguntar := .t.
*DEFAULT nAlto := GetSysMetrics(1)
*DEFAULT nAncho := GetSysMetrics(0)

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")
else
RETURN lCamReso
endif
endi
oDevMode:nFields := nOr(DM_PELSWIDTH, DM_PELSHEIGHT )
oDevMode:nPelWidth := nAncho
oDevMode:nPelHeigh := nAlto
cBuffer:=oDevMode:cBuffer
TRY
ChangeDisplaySettings(@cBuffer, 4)
lCamReso := .T.
CATCH
MsgAlert("Modo no soportado", "Error" )
END
else
MsgAlert("Modo no soportado", "Error" )
endif
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"

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Thu Mar 31, 2011 11:18 AM
Hello Byron,

Thank You very much.
The Function works perfect.
But there is still a problem, I have to find out :

After changing the Screen-resolution, I get a System-Message : cannot continue.
Maybe I have to create a extra small Exe-file.

I tested a PRG-Structure like :

Code (fw): Select all Collapse
Function MAIN()
..
..
IF CHANGE_SCR(1152, 864, .T.) = .F. // new Resolution
   MsgAlert( "Cannot change Screen-resolution !","Attention"
ELSE
   DEFINE DIALOG oWndMain FROM  0, 0 TO 260, 400 PIXEL TRANSPARENT ;
   STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME 
   ..
   ..
   ACTIVATE DIALOG oWndMain CENTERED 

   CHANGE_SCR( 1024, 768, .T.) // old Resolution
ENDIF

RETURN NIL


Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 12:52 AM
Hi Uwe, the function should be called with .F. so It does not ask's for confirmation to change the resolution
Code (fw): Select all Collapse
CHANGE_SCR(1152, 864, .F.)


Maybe that is the problem, or it may be a problem with your video card????

I used it a while ago and did not had problems...

If you post an compiled example, I can test in my computer to see if gives me the same problem....

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 01:35 PM
Hello Byron,

the Screenshots of my Tests :

started with 1152 x 864


switching to Application Screen-resolution 1024 x 768,
the Application stopps.


Maybe it is a Dialog and not a Window ?

The Main-prgstructure :
Code (fw): Select all Collapse
FUNCTION MAIN()
LOCAL oWndMain
LOCAL nScrwidth := GetSysmetrics( 0 ) 
LOCAL nScrheight := GetSysmetrics( 1 )
LOCAL cRestart := "NO"
...
...聽 
SetBalloon( .T. ) // Balloon shape required for tooltips
c_path := CURDRIVE() + ":\" + GETCURDIR() 聽

IF nScrwidth <> 1024 .and. nScrheight <> 768
聽 聽 cRestart := "YES"
ENDIF

oFont1 := TFont():New( "Arial", 0, 16,.F.,.T., 聽0, 聽0, 聽0,.F.,.F.)

DEFINE BITMAP oAlpha FILENAME c_Path + "\bitmaps\LOGO2.bmp"

DEFINE DIALOG oWndMain FROM 聽0, 0 TO 260, 400 PIXEL TRANSPARENT ;
STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME 
...
...
@ 90, 125 BTNBMP oBtn5 OF oWndMain 聽;
SIZE 40, 40 ;
TOP NOBORDER ;
FILE c_path + "\Bitmaps\32Screen.bmp" ; 聽 聽 聽 
PROMPT " &Screen" ;
FONT oFont1 ;
ACTION ( TEST_SCR(oWndMain) ) 
oBtn5:cTooltip := 聽{ "New" + CRLF + ;
聽 聽 聽 "Screen-resolution 1024 x 768","Screen", 1, CLR_BLACK, 14089979 }
oBtn5:lTransparent := .T.
oBtn5:l2007 := .F.
oBtn5:SetColor( 16312263 )
...
...
ACTIVATE DIALOG oWndMain CENTERED ;
ON INIT GRADBRU1(oWndMain, 0.8, 8388608, 14853684, .T.) ; 
ON PAINT ABPaint( hDC, 50, 10, oAlpha:hBitmap, 255 ) 聽// Horiz / Vertical

oFont1:End() 聽

// Back to different Screen-resolution RESET
IF cRestart = "YES" 
聽 聽 CHANGE_SCR( nScrwidth, nScrheight, .T.)
ENDIF

RETURN NIL 聽

// --------- Use 1024 x 768 if Screenresolution is different ------------

FUNCTION TEST_SCR(oWndMain)

IF cRestart = "YES"
聽 聽IF CHANGE_SCR(1024, 768, .T.) = .F.
聽 聽 聽 MsgAlert( "Cannot change Screen-resolution !","Attention")
聽 聽ENDIF
ELSE
聽 聽 MsgAlert( "No Screen-resolution-change needed !","Attention" ) 
ENDIF

RETURN NIL


Added to Sample : Testbtn.prg
I got the same Result. After changing the Screen-resolution
Message : Testbtn.exe doesn't work anymore ....



Code (fw): Select all Collapse
// Defining ButtonBar buttons which uses Bitmaps files from disk

#include "FiveWin.ch"

static oWnd

//----------------------------------------------------------------------------//

function Main()

聽 聽local oBar
聽 聽local oBrush
聽 聽local oPopup

聽 聽DEFINE BRUSH oBrush COLOR nRGB( 12, 129, 87 )

聽 聽DEFINE WINDOW oWnd FROM 1, 10 TO 20, 60 ;
聽 聽 聽 TITLE "Testing Buttons from disk" ;
聽 聽 聽 BRUSH oBrush

聽 聽DEFINE BUTTONBAR oBar OF oWnd _3D

聽 聽DEFINE BUTTON OF oBar FILE "..\bitmaps\16x16\exit.bmp" ;
聽 聽 聽 ACTION MsgInfo( CHANGE_SCR( 1152, 864, .T.) ) ;
聽 聽 聽 MESSAGE "You can place..."

聽 聽MENU oPopup POPUP
聽 聽 聽 MENUITEM "Test" WHEN .f.
聽 聽 聽 MENUITEM "Test" ACTION MsgInfo( "Any action" )
聽 聽 聽 MENU
聽 聽 聽 聽 聽MENUITEM "Another" WHEN .f.
聽 聽 聽 聽 聽MENUITEM "More..."
聽 聽 聽 ENDMENU
聽 聽ENDMENU

聽 聽DEFINE BUTTON OF oBar FILE "..\bitmaps\16x16\Open.bmp" GROUP ;
聽 聽 聽 ACTION MsgInfo( FWVERSION ) ;
聽 聽 聽 MESSAGE "Any BMP File here..." ;
聽 聽 聽 MENU oPopup

聽 聽DEFINE BUTTON OF oBar FILE "..\bitmaps\16x16\Cut.bmp" ;
聽 聽 聽 ACTION MsgInfo( FWVERSION ) ;
聽 聽 聽 MESSAGE "Reading it from disk !!!"

聽 聽SET MESSAGE OF oWnd TO FWVERSION + " " + FWCOPYRIGHT

聽 聽ACTIVATE WINDOW oWnd

return nil

///////////////////////////////////////////////////////////////////
/// FUNCION CamReso
/// CAMBIA RESOLUCION DE PANTALLA TEMPORALMENTE
/// Manuel Valdenebro 2008
/// Adaptaci贸n ChangeRes() Marcelo Gomes/Yuri Marcelino
/// <!-- m --><a class="postlink" href="http://www.fivewin.com.br/forum/topic.a">http://www.fivewin.com.br/forum/topic.a</a><!-- m --> ... C_ID=10465
/// ---------------------------------------
// nAncho ancho pantalla
// nAlto alto pantalla
// lPreguntar si pregunta antes de realizar el cambio
///////////////////////////////////////////////////////////////////

#Include "dll.ch"
#Include "Struct.ch"

Function CHANGE_SCR(nScrwidth, nScrheight, lChange)
Local DM_PELSWIDTH := nHex("80000")
Local DM_PELSHEIGHT := nHex("100000")
Local oDevMode
Local lPosible
Local cBuffer
Local lScrReso := .f.
*DEFAULT lPreguntar := .t.
*DEFAULT nScrwidth := GetSysMetrics(1) // Width
*DEFAULT nScrheight := GetSysMetrics(0) // Height

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)
// Change if possible
IF lPosible
聽 聽 IF lChange
聽 聽 聽 聽 IF MsgYesNo("Do You want to change the Resolution ?", "Attention")
聽 聽 聽 聽 ELSE
聽 聽 聽 聽 聽 聽 RETURN lScrReso
聽 聽 聽 聽 ENDIF
聽 聽 ENDIF
聽 聽 oDevMode:nFields := nOr(DM_PELSWIDTH, DM_PELSHEIGHT )
聽 聽 oDevMode:nPelWidth := nScrwidth
聽 聽 oDevMode:nPelHeigh := nScrheight
聽 聽 cBuffer:=oDevMode:cBuffer
聽 聽 TRY
聽 聽 聽 聽 ChangeDisplaySettings(@cBuffer, 4)
聽 聽 聽 聽 lScrReso := .T.
聽 聽 CATCH
聽 聽 聽 聽 MsgAlert("Modo no soportado", "Error" )
聽 聽 END
ELSE
聽 聽 MsgAlert("Modo no soportado", "Error" )
ENDIF

RETURN lScrReso


//----------------------------------------------------------------------------//

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"


Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 04:11 PM

Hi Uwe, I confirm that there is a problem with the code!!!

I was able to temporaly change the resolution by using the function directly right after declaring Local Variables without using a button to call it. No error was produced, but the window was not created and the original resolution was restored after a few seconds...

Sorry I can not help you any further in the issue...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 04:27 PM

I just read in the Brasilian forum, that it seem that it produces the error when using xHarbour...

I don't use Harbour, maybe someone can test it...

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 05:14 PM
Hello

it's a sample using the function from C

Code (fw): Select all Collapse
#include "fivewin.ch"


function main()

? CHANGEDISLPAYRESOLUTION( 1440, 900 )

return nil


#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>


HB_FUNC( CHANGEDISLPAYRESOLUTION )
{
   DWORD dmBitsPerPel = hb_pcount() > 2 ? hb_parnl( 3 ) : 0 ;
   DWORD dmPelsWidth  = hb_parnl( 1 );
   DWORD dmPelsHeight = hb_parnl( 2 );   
     DEVMODE DevMode;
    
   EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DevMode );
   
   DevMode.dmPelsWidth = dmPelsWidth;
   DevMode.dmPelsHeight = dmPelsHeight;
   if( dmBitsPerPel > 0 )
      DevMode.dmBitsPerPel = dmBitsPerPel;

   hb_retnl( ChangeDisplaySettings( &DevMode, CDS_RESET ) );
    
}

#pragma ENDDUMP
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 06:33 PM
Daniel,

Thank You very much.
This Function works GREAT without any Problems.
As well the RESET, to restore the old Screen-resolution after finishing the Application.
No Validation needed ( works in silent Mode ).
It's funny, that calling original API-functions, making Problems.

CHANGEDISLPAYRESOLUTION( 1152, 864 )
must use supported Values :
1024 x 768
1152 x 864
1280 x 720
1280 x 768
1280 x 960
1280 x 1024
1600 x 1200

Sample :
Code (fw): Select all Collapse
#include "FiveWin.ch"

FUNCTION MAIN()
LOCAL oWndMain
LOCAL nScrwidth := GetSysmetrics( 0 ), nScrheight := GetSysmetrics( 1 )

IF nScrwidth <> 1024 .and. nScrheight <> 768
聽 聽 聽CHANGEDISLPAYRESOLUTION( 1024, 768 ) // Application Screen-resolution
ENDIF

DEFINE DIALOG oWndMain FROM 聽0, 0 TO 260, 400 PIXEL TRANSPARENT ;
STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME 
// ...
// ...
ACTIVATE DIALOG oWndMain CENTERED 

// Back to different Screen-resolution RESET
IF nScrwidth <> 1024 .and. nScrheight <> 768
聽 聽 聽CHANGEDISLPAYRESOLUTION( nScrwidth, nScrheight )
ENDIF

RETURN NIL 聽

// ----------------

#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>


HB_FUNC( CHANGEDISLPAYRESOLUTION )
{
聽 聽DWORD dmBitsPerPel = hb_pcount() > 2 ? hb_parnl( 3 ) : 0 ;
聽 聽DWORD dmPelsWidth 聽= hb_parnl( 1 );
聽 聽DWORD dmPelsHeight = hb_parnl( 2 ); 聽 
聽 聽 聽DEVMODE DevMode;
聽 聽 
聽 聽EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DevMode );
聽 聽
聽 聽DevMode.dmPelsWidth = dmPelsWidth;
聽 聽DevMode.dmPelsHeight = dmPelsHeight;
聽 聽if( dmBitsPerPel > 0 )
聽 聽 聽 DevMode.dmBitsPerPel = dmBitsPerPel;

聽 聽hb_retnl( ChangeDisplaySettings( &DevMode, CDS_RESET ) );
聽 聽 
}

#pragma ENDDUMP


Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 07:09 PM

Am I missing something???

I Compiled Uwe's sample, but the resolution does not changes!!!!

When I press escape to exit, I see the screen blink, but nothing else happens!!!!

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 07:34 PM

Byron

did you tested my sample?

Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 08:01 PM
Daniel Garcia-Gil wrote:Byron

did you tested my sample?


Yes I did; I got a dialog Alert:

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 08:05 PM
Bayron


you're trying set a mode not supported...

Code (fw): Select all Collapse
DISP_CHANGE_SUCCESSFUL=  0      ;The settings change was successful.
DISP_CHANGE_RESTART=     1  ;The computer must be restarted in order for the graphics mode to work.
DISP_CHANGE_FAILED=     -1  ;The display driver failed the specified graphics mode.
DISP_CHANGE_BADMODE=    -2  ;The graphics mode is not supported.
DISP_CHANGE_NOTUPDATED= -3      ;Unable to write settings to the registry.
DISP_CHANGE_BADFLAGS=   -4      ;An invalid set of flags was passed in.
DISP_CHANGE_BADPARAM=   -5  ; Bad parameters
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 08:15 PM
Thanks Daniel,
That is why I compiled Uwe's sample...

I did not get the error, but the resolution does not changes....

By the way, the resolution in your sample should be supported in my system!!!



Maybe it has something to do that I have 2 monitors???

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: Changing Screen-resolution to Applic.-resol. at Runtime ?

Posted: Fri Apr 01, 2011 08:20 PM
A better sample with Button-selection :
( The Exit-button restores to original Screen-resolution )



Code (fw): Select all Collapse
#include "FiveWin.ch"

FUNCTION MAIN()
LOCAL oWndMain, oFont
LOCAL nScrwidth := GetSysmetrics( 0 ), nScrheight := GetSysmetrics( 1 )

// adjust to Application Screen-resolution
// --------------------------------------------------
IF nScrwidth <> 1024 .and. nScrheight <> 768
聽 聽 聽CHANGEDISLPAYRESOLUTION( 1024, 768 ) 
ENDIF

DEFINE FONT oFont NAME 'MS Sans Serif' SIZE 16, 16

DEFINE DIALOG oWndMain FROM 聽0, 0 TO 260, 400 PIXEL TRANSPARENT ;
STYLE WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_THICKFRAME 

@ 15,30 BUTTON "Exit" size 100,25 font oFont OF oWndMain PIXEL ;
ACTION ( nScrwidth := 1024, ; // Application Screen-resolution
聽 聽 聽 聽 nScrheight := 768, ;
聽 聽 聽 聽 oWndMain:End() )

@ 45,30 BUTTON "1280 x 720" size 100,25 font oFont OF oWndMain PIXEL ;
ACTION ( CHANGEDISLPAYRESOLUTION( 1280, 720 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽nScrwidth := GetSysmetrics( 0 ), ;
聽 聽 聽 聽 聽nScrheight := GetSysmetrics( 1 ) )

@ 75,30 BUTTON "1280 x 720" size 100,25 font oFont OF oWndMain PIXEL ;
ACTION ( CHANGEDISLPAYRESOLUTION( 1280, 1024 ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽nScrwidth := GetSysmetrics( 0 ), ;
聽 聽 聽 聽 聽nScrheight := GetSysmetrics( 1 ) )

ACTIVATE DIALOG oWndMain CENTERED 

oFont:End()

// RESET to 1024 x 768
// ------------------------
CHANGEDISLPAYRESOLUTION( nScrwidth, nScrheight )

RETURN NIL 聽

// ----------------

#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>


HB_FUNC( CHANGEDISLPAYRESOLUTION )
{
聽 聽DWORD dmBitsPerPel = hb_pcount() > 2 ? hb_parnl( 3 ) : 0 ;
聽 聽DWORD dmPelsWidth 聽= hb_parnl( 1 );
聽 聽DWORD dmPelsHeight = hb_parnl( 2 ); 聽 
聽 聽 聽DEVMODE DevMode;
聽 聽 
聽 聽EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DevMode );
聽 聽
聽 聽DevMode.dmPelsWidth = dmPelsWidth;
聽 聽DevMode.dmPelsHeight = dmPelsHeight;
聽 聽if( dmBitsPerPel > 0 )
聽 聽 聽 DevMode.dmBitsPerPel = dmBitsPerPel;

聽 聽hb_retnl( ChangeDisplaySettings( &DevMode, CDS_RESET ) );
聽 聽 
}

#pragma ENDDUMP


Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.