FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Resolution of monitor
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Resolution of monitor
Posted: Sun Sep 04, 2022 05:25 PM
Like in this example Jimmy. The problem is that it works on WINDOWS 7, but it doesn't work on WNDOWS 10, you know?

Como en este ejemplo Jimmy. El problema es que funciona en WINDOWS 7, pero no funciona en WINDOWS 10, ¿Comprendes?

Code (fw): Select all Collapse
// C:\FWH..\SAMPLES\RESOLU2.PRG

#include 'fivewin.ch'
#Include "dll.ch"
#Include "Struct.ch"

FUNCTION MAIN()

   LOCAL nResoAncho := GetSysMetrics(0)

   IF nResoAncho < 1280 .OR. nResoAncho > 1280

   // CamReso( 800, 600)

   CamReso( 1280, 768)

   MSGINFO('HECHO. AQUI PUEDES INICIAR TU PROGRAMA ELABORADO PARA 1280 X 768')

   ENDIF

RETU nil

Function CamReso( nAncho, nAlto )

   Local DM_PELSWIDTH := nHex("80000")
   Local DM_PELSHEIGHT := nHex("100000")
   Local oDevMode
   Local lPosible
   Local cBuffer
   Local lCamReso := .f.

   DEFAULT nAncho := GetSysMetrics(0), nAlto := GetSysMetrics(1)

   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
   lPosible := EnumDisplaySettings(0, 0, @cBuffer)

   IF lPosible

      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 STATIC FUNCTION ChangeDisplaySettings(@lpDevMode AS LPSTR,;
dwFlags AS DWORD) AS DWORD PASCAL;
FROM "ChangeDisplaySettingsA" LIB "User32.dll"

DLL32 FUNCTION ExitWindowsEx(uFlags AS DWORD,;
dwReserved AS DWORD) AS DWORD PASCAL;
LIB "user32.dll"

// FIN


Regards, saludos
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Resolution of monitor
Posted: Sun Sep 04, 2022 06:32 PM
hi
karinha wrote:The problem is that it works on WINDOWS 7, but it doesn't work on WNDOWS 10, you know?

it work for me as expect under Windows 10 (32 & 64 Bit), 11 and DEV Insider 25193
Code (fw): Select all Collapse
#INCLUDE "fivewin.CH"

#define DESKTOPVERTRES       0x0075   // (117) Vertical height  of entire desktop in pixels
#define DESKTOPHORZRES       0x0076   // (118) Horizontal width of entire desktop in pixels

PROCEDURE MAIN
LOCAL nWidth    := 800
LOCAL nHeight   := 600
LOCAL oWnd, oFont, hDC
LOCAL Vertical
LOCAL Horizontal

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 18
   DEFINE WINDOW oWnd FROM 0, 0 TO 100,800 PIXEL //nHeight, nWidth  // NOSYSMENU NOCAPTION BORDER NONE

   hDC := GetDc(0)
   Vertical   := GetDeviceCaps(hDC, 0x0075)
   Horizontal := GetDeviceCaps(hDC, 0x0076)
   msginfo(HB_VALTOSTR(Horizontal) +" x "+HB_VALTOSTR(Vertical))

   ACTIVATE WINDOW oWnd CENTER

RETURN
greeting,

Jimmy
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Resolution of monitor
Posted: Mon Sep 05, 2022 12:29 PM

Hola Jimmy. Creo que no entendiste lo que quiero. Por favor, para comprender, debe probar el ejemplo que publiqué anteriormente en una máquina con WINDOW 7 y luego en una máquina con WINDOWS 10, entonces comprenderá lo que quiero, ¿de acuerdo?

Hello Jimmy. I think you didn't understand what I want. Please, to understand, you need to test the example I posted above on a machine with WINDOW 7 and then on a machine with WINDOWS 10, then you will understand what I want, ok?

Gracias, thanks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Resolution of monitor
Posted: Mon Sep 05, 2022 05:14 PM

hi karinha,

i have run your Sample to "switch" Resolution
but my Answer is not a Solution to "switch"

it "just" is to get "native" (real) Size of Display under Windows 7, 8, 10, 11 and DEV Insider
which is the Theme of this Thread

greeting,

Jimmy
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Resolution of monitor
Posted: Tue Sep 06, 2022 01:14 PM
Jimmy wrote:hi karinha,

i have run your Sample to "switch" Resolution
but my Answer is not a Solution to "switch"

it "just" is to get "native" (real) Size of Display under Windows 7, 8, 10, 11 and DEV Insider
which is the Theme of this Thread


Ok Jimmy, I appreciate the intention to help. Thank you very much.

Ok Jimmy, agradezco la intención de ayudar. Muchas gracias.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 08:52 AM
karinha wrote:Like in this example Jimmy. The problem is that it works on WINDOWS 7, but it doesn't work on WNDOWS 10, you know?

Como en este ejemplo Jimmy. El problema es que funciona en WINDOWS 7, pero no funciona en WINDOWS 10, ¿Comprendes?
Code (fw): Select all Collapse
// C:\FWH..\SAMPLES\RESOLU2.PRG

#include 'fivewin.ch'
#Include "dll.ch"
#Include "Struct.ch"

FUNCTION MAIN()

   LOCAL nResoAncho := GetSysMetrics(0)

   IF nResoAncho < 1280 .OR. nResoAncho > 1280

   // CamReso( 800, 600)

   CamReso( 1280, 768)

   MSGINFO('HECHO. AQUI PUEDES INICIAR TU PROGRAMA ELABORADO PARA 1280 X 768')

   ENDIF

RETU nil

Function CamReso( nAncho, nAlto )

   Local DM_PELSWIDTH := nHex("80000")
   Local DM_PELSHEIGHT := nHex("100000")
   Local oDevMode
   Local lPosible
   Local cBuffer
   Local lCamReso := .f.

   DEFAULT nAncho := GetSysMetrics(0), nAlto := GetSysMetrics(1)

   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
   lPosible := EnumDisplaySettings(0, 0, @cBuffer)

   IF lPosible

      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 STATIC FUNCTION ChangeDisplaySettings(@lpDevMode AS LPSTR,;
dwFlags AS DWORD) AS DWORD PASCAL;
FROM "ChangeDisplaySettingsA" LIB "User32.dll"

DLL32 FUNCTION ExitWindowsEx(uFlags AS DWORD,;
dwReserved AS DWORD) AS DWORD PASCAL;
LIB "user32.dll"

// FIN
Regards, saludos
Hi Karinha,

It works in W10. Is it possiple to change display scale factor with this?

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 09:01 AM
I have a similar problem, I'll explain
I create the dialogues with

Code (fw): Select all Collapse
local nWd  := GetSysMetrics(0) * .58
local nHt  := (GetSysMetrics(1) / 2.5 )

DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL

DEFINE BUTTONBAR oBar OF oDlg  SIZE 80,70  BOTTOM NOBORDER  2015

ACTIVATE DIALOG oDlg CENTERED


on Miix320 Lenovo ( tab10) 1920 x 1200 Pixel

I have the dialog smaller and the button bar on too hight




and it happens that in Win10 as in Win7, depending on the monitor, I have the buttonbar too high

for a sample : if th emonitor resolution have 1280x 1024 run ok

if I have the same resolution on a TAblet 10 window the dialog is wrong
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 09:25 AM

it is better to use or

local nWd := GetSysMetrics(0) * .90

local nHt := (GetSysMetrics(1) / 2.1 )

or

local nHt := Int( ScreenHeight() * 0.55 )

local nWd := Int( ScreenWidth() * 0.90 )

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 02:11 PM
Code (fw): Select all Collapse
        nResHoriz := oWnd:nHorzRes() // retorna a resolucao horizontal
        nResVert  := oWnd:nVertRes() // retorna a resolucao vertical


        // complete...

        IF nResHoriz     = 1440 .AND. nResVert = 900 // RESOLUTION...

           DEFINE DIALOG...


        ELSEIF nResHoriz = 1366 .AND. nResVert = 768


        ELSEIF nResHoriz = 1360 .AND. nResVert = 768


        ELSEIF nResHoriz = 1280 .AND. nResVert = 768


        ELSEIF nResHoriz = 1280 .AND. nResVert = 720


        ELSEIF nResHoriz = 1280 .AND. nResVert = 960


        ELSEIF nResHoriz = 1280 .AND. nResVert = 800


        ELSEIF nResHoriz = 1280 .AND. nResVert = 720


        ELSEIF nResHoriz = 1280 .AND. nResVert = 600


        ELSEIF nResHoriz = 1600 .AND. nResVert = 1200


        ELSEIF nResHoriz = 1680 .AND. nResVert = 1050


        ELSEIF nResHoriz = 2560 .AND. nResVert = 1600


        ELSEIF nResHoriz = 1024 .AND. nResVert = 768

           IF ISWINXP()

           ELSE

           ENDIF

        ELSE

           IF ISWINXP()

            ELSE

           ENDIF

        ENDIF
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 07:57 AM
karinha wrote:
Code (fw): Select all Collapse
        nResHoriz := oWnd:nHorzRes() // retorna a resolucao horizontal
        nResVert  := oWnd:nVertRes() // retorna a resolucao vertical


        // complete...

        IF nResHoriz     = 1440 .AND. nResVert = 900 // RESOLUTION...

           DEFINE DIALOG...


        ELSEIF nResHoriz = 1366 .AND. nResVert = 768


        ELSEIF nResHoriz = 1360 .AND. nResVert = 768


        ELSEIF nResHoriz = 1280 .AND. nResVert = 768


        ELSEIF nResHoriz = 1280 .AND. nResVert = 720


        ELSEIF nResHoriz = 1280 .AND. nResVert = 960


        ELSEIF nResHoriz = 1280 .AND. nResVert = 800


        ELSEIF nResHoriz = 1280 .AND. nResVert = 720


        ELSEIF nResHoriz = 1280 .AND. nResVert = 600


        ELSEIF nResHoriz = 1600 .AND. nResVert = 1200


        ELSEIF nResHoriz = 1680 .AND. nResVert = 1050


        ELSEIF nResHoriz = 2560 .AND. nResVert = 1600


        ELSEIF nResHoriz = 1024 .AND. nResVert = 768

           IF ISWINXP()

           ELSE

           ENDIF

        ELSE

           IF ISWINXP()

            ELSE

           ENDIF

        ENDIF
Regards, saludos.



seem a joke.....

local nResHoriz := oWnd:nHorzRes()
local nResVert := oWnd:nVertRes()

where is oWnd ?
I don't always have the main window where I can find the oWnd?
Such a solution seems strange to me
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 08:03 AM

Function test(oWnd)

local nResHoriz := oWnd:nHorzRes() // retorna a resolucao horizontal

local nResVert := oWnd:nVertRes() // retorna a resolucao vertical

? nResHoriz,nResVert

Error occurred at: 01/10/24, 09:01:40

Error description: Error BASE/1004 No exported method: NHORZRES

Args:

 [   1] = U

Stack Calls

===========

Called from: => NHORZRES( 0 )

Called from: test.prg => TEST( 48 )

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 11:54 AM
Dear Silvio,
Args:
[ 1] = U
oWnd is nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 12:16 PM
Code (fw): Select all Collapse
// C:\FWH\SAMPLES\SILVRESO.PRG

#include "FiveWin.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL oBar

   DEFINE WINDOW oWnd TITLE "Silvio Resolution"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION( Test_Resol( oWnd ) )

   SET MESSAGE OF oWnd TO "Silvio Resolution" NOINSET CLOCK DATE KEYBOARD

   ACTIVATE WINDOW oWnd

RETURN NIL

FUNCTION Test_Resol( oWnd )

   LOCAL nResHoriz := oWnd:nHorzRes() // retorna a resolucao horizontal
   LOCAL nResVert  := oWnd:nVertRes() // retorna a resolucao vertical

   ? nResHoriz, nResVert  // 1024 X 768 my computer.

RETURN NIL

// FIN / END
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 12:55 PM
I hope you understand now. I use different resolutions using RESOURCES, I calculate the coordinates in WORKSHOP.exe

Espero que lo entiendas ahora. Utilizo diferentes resoluciones usando RECURSOS, calculo las coordenadas en WORKSHOP.exe
Code (fw): Select all Collapse
// C:\FWH\SAMPLES\SILVRESO.PRG

#include "FiveWin.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL oBar

   DEFINE WINDOW oWnd TITLE "Silvio's Resolution"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION( Test_Resol( oWnd ) )

   SET MESSAGE OF oWnd TO "Silvio's Resolution" NOINSET CLOCK DATE KEYBOARD

   ACTIVATE WINDOW oWnd MAXIMIZED

RETURN NIL

FUNCTION Test_Resol( oWnd )

   LOCAL oDlg, oBar, oFont, nAlturaScr, nLarguraScr, cTitle
   LOCAL nResHoriz := oWnd:nHorzRes() // retorna a resolucao horizontal
   LOCAL nResVert  := oWnd:nVertRes() // retorna a resolucao vertical

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, - 14 BOLD

   IF nResHoriz     = 1440 .AND. nResVert = 900 // RESOLUTIONS...


   ELSEIF nResHoriz = 1366 .AND. nResVert = 768


   ELSEIF nResHoriz = 1360 .AND. nResVert = 768


   ELSEIF nResHoriz = 1280 .AND. nResVert = 768


   ELSEIF nResHoriz = 1280 .AND. nResVert = 720


   ELSEIF nResHoriz = 1280 .AND. nResVert = 960


   ELSEIF nResHoriz = 1280 .AND. nResVert = 800


   ELSEIF nResHoriz = 1280 .AND. nResVert = 720


   ELSEIF nResHoriz = 1280 .AND. nResVert = 600


   ELSEIF nResHoriz = 1600 .AND. nResVert = 1200


   ELSEIF nResHoriz = 1680 .AND. nResVert = 1050


   ELSEIF nResHoriz = 2560 .AND. nResVert = 1600


   ELSEIF nResHoriz = 1024 .AND. nResVert = 768  // MY COMPUTER:

      nAlturaScr  := ScreenHeight() - 85 // Altura da Dialog dentro da window
      nLarguraScr := ScreenWidth()  - 10 // Lagura da Dialog dentro da window

      cTitle := "Silvio's Resolution - 1024 x 768"

      DEFINE DIALOG oDlg SIZE nLarguraScr, nAlturaScr PIXEL TRUEPIXEL ;
         FONT oFont RESIZABLE TITLE cTitle

   ELSE // continue...

   ENDIF

   DEFINE BUTTONBAR oBar OF oDlg SIZE 100, 32 2010

   DEFINE BUTTON OF oBar PROMPT "Browse" CENTER ACTION( NIL )

   DEFINE BUTTON OF oBar PROMPT "Exit" CENTER ;
      ACTION( oDlg:End(), oWnd:End() )

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

RETURN NIL

// FIN / END
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 218
Joined: Mon Feb 07, 2022 09:54 PM
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 05:55 PM
Silvio.Falconi wrote: seem a joke.....

local nResHoriz := oWnd:nHorzRes()
local nResVert := oWnd:nVertRes()

where is oWnd ?
I don't always have the main window where I can find the oWnd?
Such a solution seems strange to me
Hi Silvio,

you must not take 'oWnd' but take your dialog:
Code (fw): Select all Collapse
local  nResHoriz := oDlg:nHorzRes() 
local  nResVert  := oDlg:nVertRes()
Hope this helps

Continue the discussion