Our application does not currently handle when the user changes their setting for the normal size to one of the larger sizes (125% or 150%).
How can we programmically detect this setting and alert the user to that fact so the setting can be changed back.
Cliff
Detecting when user has set Screen to larger than default
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Detecting when user has set Screen to larger than defaul
Cliff:
is this what you're looking for ?
*********************
function issmallfonts(lDisplay)
*********************
// Pixels per inch if small or large font is active
#define SMALLFONT 96
#define LARGEFONT 120
// DeviceCap ID to retrieve device pix/inch attribute
#define LOGPIXELSX 88
#define LOGPIXELSY 90
LOCAL oDesktop := AppDesktop()
LOCAL hWND
LOCAL hDC
LOCAL nLogPix,cMsg
default lDisplay:=.f.
IF(ValType(oDesktop)!="O" .AND. !oDesktop:IsDerivedFrom("XbpIWindow"))
// Non GUI mode
RETURN(NIL)
ENDIF
hWND := oDesktop:GetHWND()
hDC := GetDC(hWND)
IF(hDC==-1)
// could not aquire device
RETURN(NIL)
ENDIF
nLogPix := GetDeviceCaps(hDC,LOGPIXELSX)
ReleaseDC(hWND,hDC)
IF lDisplay
cMsg:="Font Size is "+dc_xtoc(nLogPix)+" DPI"
cMsg+=". 96 DPI is the only DPI setting compatible with CUS Software"
dc_msgbox(cMsg)
ENDIF
RETURN(nLogPix== SMALLFONT)
DLLFUNCTION GetDC( nHWND ) USING STDCALL FROM USER32.DLL
DLLFUNCTION ReleaseDC( nHWND, nHDC ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetDeviceCaps( nHWND, nIndex ) USING STDCALL FROM GDI32.DLL
is this what you're looking for ?
*********************
function issmallfonts(lDisplay)
*********************
// Pixels per inch if small or large font is active
#define SMALLFONT 96
#define LARGEFONT 120
// DeviceCap ID to retrieve device pix/inch attribute
#define LOGPIXELSX 88
#define LOGPIXELSY 90
LOCAL oDesktop := AppDesktop()
LOCAL hWND
LOCAL hDC
LOCAL nLogPix,cMsg
default lDisplay:=.f.
IF(ValType(oDesktop)!="O" .AND. !oDesktop:IsDerivedFrom("XbpIWindow"))
// Non GUI mode
RETURN(NIL)
ENDIF
hWND := oDesktop:GetHWND()
hDC := GetDC(hWND)
IF(hDC==-1)
// could not aquire device
RETURN(NIL)
ENDIF
nLogPix := GetDeviceCaps(hDC,LOGPIXELSX)
ReleaseDC(hWND,hDC)
IF lDisplay
cMsg:="Font Size is "+dc_xtoc(nLogPix)+" DPI"
cMsg+=". 96 DPI is the only DPI setting compatible with CUS Software"
dc_msgbox(cMsg)
ENDIF
RETURN(nLogPix== SMALLFONT)
DLLFUNCTION GetDC( nHWND ) USING STDCALL FROM USER32.DLL
DLLFUNCTION ReleaseDC( nHWND, nHDC ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetDeviceCaps( nHWND, nIndex ) USING STDCALL FROM GDI32.DLL
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises
Re: Detecting when user has set Screen to larger than defaul
work with XP and Vista/Win7 but not with Window 10.bwolfsohn wrote:Code: Select all
nLogPix := GetDeviceCaps(hDC,LOGPIXELSX)
you need "new" Constante for API Function GetDeviceCaps()
greetings by OHR
Jimmy
Jimmy
Re: Detecting when user has set Screen to larger than defaul
older OS like XP use Grafic Driver to change Resolution and/or "Zoom"Cliff Wiernik wrote:... when the user changes their setting for the normal size to one of the larger sizes (125% or 150%).
since Vista Desktop > 125 % is using "virtual" Desktop and DPI is 96
not sure about Windows 8.1 but in Windows 10 it is always DPI 96 when using LOGPIXELSX
so if you want real "native" Resolution you must use these Constante
Code: Select all
#include "dll.ch"
#define DESKTOPVERTRES 117
#define DESKTOPHORZRES 118
// link with /PM:PM
PROCEDURE MAIN
LOCAL hDC := GetDC(0)
LOCAL nDHORZRES := GetDeviceCaps( hDC, DESKTOPHORZRES ) // native Monitor Size !
LOCAL nDVERTRES := GetDeviceCaps( hDC, DESKTOPVERTRES ) // native Monitor Size !
? AppDesktop():Currentsize()
? nDHORZRES , nDVERTRES
WAIT
RETURN
DLLFUNCTION GetDC( nHWND ) USING STDCALL FROM USER32.DLL
DLLFUNCTION ReleaseDC( nHWND, nHDC ) USING STDCALL FROM USER32.DLL
DLLFUNCTION GetDeviceCaps( nHWND, nIndex ) USING STDCALL FROM GDI32.DLL
greetings by OHR
Jimmy
Jimmy
Re: Detecting when user has set Screen to larger than defaul
forgot to say : make you Xbase++ App "Desktop-aware" using this in Manifest
more read here https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Code: Select all
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</windowsSettings>
</application>
greetings by OHR
Jimmy
Jimmy
-
- Posts: 605
- Joined: Thu Jan 28, 2010 9:11 pm
- Location: Steven Point, Wisconsin USA
- Contact:
Re: Detecting when user has set Screen to larger than defaul
Thanks Brian and Jimmy,
These do what I need to do.
These do what I need to do.