Page 1 of 2
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 8:52 am
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.
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 9:01 am
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
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
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 9:25 am
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 )
Re: Resolution of monitor
Posted: Tue Jan 09, 2024 2:11 pm
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.
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 7:57 am
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
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 8:03 am
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 )
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 11:54 am
by Antonio Linares
Dear Silvio,
Args:
[ 1] = U
oWnd is nil
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 12:16 pm
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
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 12:55 pm
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
Re: Resolution of monitor
Posted: Wed Jan 10, 2024 5:55 pm
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