Page 1 of 2

Resolution of monitor

PostPosted: Thu Dec 23, 2021 1:47 pm
by Natter
Hi,

The resolution of my monitor is 1920 x 1080. However, the ScrResolution() function returns
{ 1536, 864 }. Why ?

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 2:28 pm
by Rick Lipkin
Natter

Try it this way ...

Code: Select all  Expand view

nSCR1 := GetSysMetrics(0)
nSCR2 := GetSysMetrics(1)
 


This will give you the horizontal and vertical resolution ...

Rick Lipkin

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 2:43 pm
by Natter
I tried it. Getsystemmetrics returns the same values. Mysticism :(

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 2:51 pm
by hmpaquito

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 3:02 pm
by Natter
So what ?

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 4:25 pm
by dutch
Hi Natter,

Because of Display Setup (Scale and Layout is 125%)
Natter wrote:Hi,

The resolution of my monitor is 1920 x 1080. However, the ScrResolution() function returns
{ 1536, 864 }. Why ?

Image

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 4:56 pm
by Natter
Yes, dutch, you're right. Thanks !

Can I get this scale from FWH ?

Re: Resolution of monitor

PostPosted: Thu Dec 23, 2021 11:31 pm
by Marc Venken

Re: Resolution of monitor

PostPosted: Sat Dec 25, 2021 3:21 pm
by driessen
Is there a function that can read the scaling of your desktop?

Thanks.

Re: Resolution of monitor

PostPosted: Sat Dec 25, 2021 9:59 pm
by Natter
It is not possible to get DPI yet. It might be worth trying in the registry

Re: Resolution of monitor

PostPosted: Sun Dec 26, 2021 5:49 am
by Jimmy
hi,

there are different Way to get Scale-Factor.

for single Monitor you can use "real" / "virtual" Desktop Size to get Scale-Factor

Code: Select all  Expand view
#define HORZRES              0x0008   // (  8) Horizontal width in pixels
#define VERTRES              0x000A   // ( 10) Vertical width in pixels
#define LOGPIXELSX           0x0058   // ( 88) Logical pixels/inch in X
#define LOGPIXELSY           0x005A   // ( 90) Logical pixels/inch in Y
#define DESKTOPVERTRES       0x0075   // (117) Vertical height  of entire desktop in pixels
#define DESKTOPHORZRES       0x0076   // (118) Horizontal width of entire desktop in pixels

Function GetDeskSize(nHDC,lVirtual)
LOCAL nWidth,nHeight
   nWidth  := HMG_CallDLL('GDI32.dll', DLL_OSAPI, 'GetDeviceCaps', nHDC, iif(lVirtual, HORZRES, DESKTOPHORZRES))
   nHeight := HMG_CallDLL('GDI32.dll', DLL_OSAPI, 'GetDeviceCaps', nHDC, iif(lVirtual, VERTRES, DESKTOPVERTRES))
RETURN{nWidth,nHeight}
 

---

for multi-Monitor you need

MonitorFromWindow https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfromwindow
GetScaleFactorForMonitor https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorformonitor
DEVICE_SCALE_FACTOR https://docs.microsoft.com/en-us/windows/win32/api/shtypes/ne-shtypes-device_scale_factor

GetScaleFactorForDevice is IMHO outdate
https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorfordevice

Re: Resolution of monitor

PostPosted: Sun Dec 26, 2021 10:57 am
by Natter
Jimmy, great! GetDeviceCaps(DC, 117/118) works correctly

Re: Resolution of monitor

PostPosted: Sun Sep 04, 2022 4:12 pm
by karinha
Hi Jimmy, how do I do this in FiveWin? I don't use HMG.

Hola Jimmy, ¿cómo hago esto en FiveWin? No uso HMG.

Regards, saludos.

Re: Resolution of monitor

PostPosted: Sun Sep 04, 2022 4:49 pm
by Jimmy
hi karinha,
karinha wrote:how do I do this in FiveWin? I don't use HMG.

FiveWin have in c:\fwh\source\winapi\device.c
Code: Select all  Expand view
HB_FUNC( GETDEVICECAPS )     //  ()    HDC, int iIndex

so as Natter wrote use
Code: Select all  Expand view
#define DESKTOPVERTRES       0x0075   // (117) Vertical height  of entire desktop in pixels
#define DESKTOPHORZRES       0x0076   // (118) Horizontal width of entire desktop in pixels

   Vertical   := GetDeviceCaps(DC, 0x0075)
   Horizontal := GetDeviceCaps(DC, 0x0076)

Re: Resolution of monitor

PostPosted: Sun Sep 04, 2022 5:06 pm
by karinha
Hola Jimmy, ¿puedes hacer un ejemplo completo y funcional? Necesito cambiar la RESOLUCIÓN DEL VIDEO a 1280x768 en tiempo real y luego volver a la RESOLUCIÓN DEL CLIENTE como estaba antes. ¿Es posible o no?

Hi Jimmy, can you make a complete and working example? I need to change the VIDEO RESOLUTION to 1280x768 in realtime, and then go back to CLIENT RESOLUTION as it was before. Is it possible or not?

WINDOW 7 and WINDOWS 10 please.

Gracias, thanks.

Origen:

http://forums.fivetechsupport.com/viewtopic.php?f=6&t=42143&sid=f7177597dbec68af574f19f84a5e1875

Regards, saludos.