Detecting when user has set Screen to larger than default

This forum is for eXpress++ general support.
Post Reply
Message
Author
Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Detecting when user has set Screen to larger than default

#1 Post 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

bwolfsohn
Posts: 649
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: Detecting when user has set Screen to larger than defaul

#2 Post 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
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

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Detecting when user has set Screen to larger than defaul

#3 Post 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()
greetings by OHR
Jimmy

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Detecting when user has set Screen to larger than defaul

#4 Post 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
greetings by OHR
Jimmy

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Detecting when user has set Screen to larger than defaul

#5 Post 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
greetings by OHR
Jimmy

Cliff Wiernik
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

#6 Post by Cliff Wiernik »

Thanks Brian and Jimmy,

These do what I need to do.

Post Reply