Resolution of monitor

Re: Resolution of monitor

Postby karinha » Sun Sep 04, 2022 5: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: Select all  Expand view  RUN

// 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
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Resolution of monitor

Postby Jimmy » Sun Sep 04, 2022 6: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: Select all  Expand view  RUN
#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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Resolution of monitor

Postby karinha » 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
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Resolution of monitor

Postby Jimmy » Mon Sep 05, 2022 5: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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Resolution of monitor

Postby karinha » Tue Sep 06, 2022 1: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
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Resolution of monitor

Postby Horizon » Tue Jan 09, 2024 8: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: Select all  Expand view  RUN

// 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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Resolution of monitor

Postby Silvio.Falconi » Tue Jan 09, 2024 9:01 am

I have a similar problem, I'll explain
I create the dialogues with


Code: Select all  Expand view  RUN
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


Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Postby Silvio.Falconi » Tue Jan 09, 2024 9: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Postby karinha » Tue Jan 09, 2024 2:11 pm

Code: Select all  Expand view  RUN

        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
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Resolution of monitor

Postby Silvio.Falconi » Wed Jan 10, 2024 7:57 am

karinha wrote:
Code: Select all  Expand view  RUN

        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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Postby Silvio.Falconi » Wed Jan 10, 2024 8: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Postby Antonio Linares » Wed Jan 10, 2024 11:54 am

Dear Silvio,

Args:
[ 1] = U


oWnd is nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Resolution of monitor

Postby karinha » Wed Jan 10, 2024 12:16 pm

Code: Select all  Expand view  RUN

// 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
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Resolution of monitor

Postby karinha » 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: Select all  Expand view  RUN

// 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
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Resolution of monitor

Postby Detlef » Wed Jan 10, 2024 5: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: Select all  Expand view  RUN
local  nResHoriz := oDlg:nHorzRes()
local  nResVert  := oDlg:nVertRes()


Hope this helps
User avatar
Detlef
 
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 46 guests