Page 1 of 1
					
				Detecting when user has set Screen to larger than default
				Posted: Fri May 06, 2016 11:00 am
				by Cliff Wiernik
				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
			 
			
					
				Re: Detecting when user has set Screen to larger than defaul
				Posted: Fri May 06, 2016 12:03 pm
				by bwolfsohn
				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
			 
			
					
				Re: Detecting when user has set Screen to larger than defaul
				Posted: Fri May 06, 2016 1:48 pm
				by Auge_Ohr
				bwolfsohn wrote:Code: Select all
  nLogPix := GetDeviceCaps(hDC,LOGPIXELSX)
 
work with XP and Vista/Win7 but not with Window 10.
you need "new" Constante for API Function GetDeviceCaps()
 
			
					
				Re: Detecting when user has set Screen to larger than defaul
				Posted: Fri May 06, 2016 2:07 pm
				by Auge_Ohr
				Cliff Wiernik wrote:... when the user changes their setting for the normal size to one of the larger sizes (125% or 150%).
older OS like XP use Grafic Driver to change Resolution and/or "Zoom"
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
 
			
					
				Re: Detecting when user has set Screen to larger than defaul
				Posted: Fri May 06, 2016 2:27 pm
				by Auge_Ohr
				forgot to say : make you Xbase++ App "Desktop-aware" using this in Manifest
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>
more read here 
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx 
			
					
				Re: Detecting when user has set Screen to larger than defaul
				Posted: Fri May 06, 2016 7:13 pm
				by Cliff Wiernik
				Thanks Brian and Jimmy,
These do what I need to do.