Resolution of monitor

Post Reply
Natter
Posts: 1232
Joined: Mon May 14, 2007 9:49 am

Resolution of monitor

Post by Natter »

Hi,

The resolution of my monitor is 1920 x 1080. However, the ScrResolution() function returns
{ 1536, 864 }. Why ?
User avatar
Rick Lipkin
Posts: 2668
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Resolution of monitor

Post by Rick Lipkin »

Natter

Try it this way ...

Code: Select all | Expand


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


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

Rick Lipkin
Natter
Posts: 1232
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Post by Natter »

I tried it. Getsystemmetrics returns the same values. Mysticism :(
Natter
Posts: 1232
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Post by Natter »

So what ?
User avatar
dutch
Posts: 1554
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Resolution of monitor

Post 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
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
Natter
Posts: 1232
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Post by Natter »

Yes, dutch, you're right. Thanks !

Can I get this scale from FWH ?
User avatar
Marc Venken
Posts: 1482
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Resolution of monitor

Post by Marc Venken »

Marc Venken
Using: FWH 23.08 with Harbour
User avatar
driessen
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Resolution of monitor

Post by driessen »

Is there a function that can read the scaling of your desktop?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Natter
Posts: 1232
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Post by Natter »

It is not possible to get DPI yet. It might be worth trying in the registry
User avatar
Jimmy
Posts: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Resolution of monitor

Post 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

#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
greeting,
Jimmy
Natter
Posts: 1232
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Post by Natter »

Jimmy, great! GetDeviceCaps(DC, 117/118) works correctly
User avatar
karinha
Posts: 7910
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Resolution of monitor

Post 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Jimmy
Posts: 1734
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Resolution of monitor

Post 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

HB_FUNC( GETDEVICECAPS )     //  ()    HDC, int iIndex

so as Natter wrote use

Code: Select all | Expand

#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)
greeting,
Jimmy
User avatar
karinha
Posts: 7910
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Resolution of monitor

Post 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Post Reply