Resolution of monitor

Resolution of monitor

Postby Natter » Thu Dec 23, 2021 1:47 pm

Hi,

The resolution of my monitor is 1920 x 1080. However, the ScrResolution() function returns
{ 1536, 864 }. Why ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Postby Rick Lipkin » Thu Dec 23, 2021 2:28 pm

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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Resolution of monitor

Postby Natter » Thu Dec 23, 2021 2:43 pm

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


Re: Resolution of monitor

Postby Natter » Thu Dec 23, 2021 3:02 pm

So what ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Postby dutch » Thu Dec 23, 2021 4:25 pm

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)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Resolution of monitor

Postby Natter » Thu Dec 23, 2021 4:56 pm

Yes, dutch, you're right. Thanks !

Can I get this scale from FWH ?
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Postby Marc Venken » Thu Dec 23, 2021 11:31 pm

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Resolution of monitor

Postby driessen » Sat Dec 25, 2021 3:21 pm

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
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Resolution of monitor

Postby Natter » Sat Dec 25, 2021 9:59 pm

It is not possible to get DPI yet. It might be worth trying in the registry
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Postby Jimmy » Sun Dec 26, 2021 5:49 am

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

Re: Resolution of monitor

Postby Natter » Sun Dec 26, 2021 10:57 am

Jimmy, great! GetDeviceCaps(DC, 117/118) works correctly
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Resolution of monitor

Postby karinha » Sun Sep 04, 2022 4:12 pm

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

Re: Resolution of monitor

Postby Jimmy » Sun Sep 04, 2022 4:49 pm

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

Re: Resolution of monitor

Postby karinha » Sun Sep 04, 2022 5:06 pm

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests