Resolution of monitor

Horizon
Posts: 1323
Joined: Fri May 23, 2008 1:33 pm

Re: Resolution of monitor

Post by Horizon »

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

// 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
User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Post by Silvio.Falconi »

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

Code: Select all | Expand

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: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Post by Silvio.Falconi »

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

Re: Resolution of monitor

Post by karinha »

Code: Select all | Expand

        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
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Post by Silvio.Falconi »

karinha wrote:

Code: Select all | Expand

        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: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: Resolution of monitor

Post by Silvio.Falconi »

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
Antonio Linares
Site Admin
Posts: 42270
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Resolution of monitor

Post by Antonio Linares »

Dear Silvio,
Args:
[ 1] = U
oWnd is nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Resolution of monitor

Post by karinha »

Code: Select all | Expand

// 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: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: Resolution of monitor

Post by karinha »

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

// 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
Detlef
Posts: 209
Joined: Mon Feb 07, 2022 9:54 pm

Re: Resolution of monitor

Post by Detlef »

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

local  nResHoriz := oDlg:nHorzRes() 
local  nResVert  := oDlg:nVertRes()
Hope this helps
Post Reply