TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Detecting Large Fonts via ObjectPAL
 
   
by Lance Leonard 
 Posted: 27 July 2000
 
   
 
 Applies to: Paradox 7.32 and later
 
   
 
Audience: Intermediate
 
       
   

Question: How can I tell if the machine currently running Paradox is configured to use Large Fonts?

Answer: The following code sample demonstrates this:

Uses GDI32
   GetDeviceCaps( HDC CLONG, nIndex CLONG ) CLONG
endUses

Uses USER32
   GetDC( HWND CLONG ) CWORD
   ReleaseDC( HWND CLONG, HDC CLONG )
endUses

method hasLargeFonts() Logical
; --------------------------------------------------------
; Returns a Logical indicating whether or not Large Fonts
; are set in Display Properties.
; --------------------------------------------------------
var
   liResult longInt  ; Value returned to calling process
   liHDC    longInt  ; Holds device context for screen
endVar

const
   LOGPIXELSX = 88   ; Value of relevant Windows constant
endConst

   ; Obtain the handle of the device displaying Paradox.
   liHDC = GetDC( 0 )

   ; Determine the number of pixels per inch (PPI) on
   ; the device handle we've obtained.

   liResult = getDeviceCaps( liHDC, LOGPIXELSX );

   ; IMPORTANT: Release the device context or we'll
   ; have a resource leak.

   releaseDC( 0, liHDC )

   ; If PP=120, Large Fonts are enabled.  FWIW, the PPI
   ; for Small Fonts is 96.

   return ( liResult = 120 )

endMethod

[Download Sample]

How it works:

The Windows API contains a number of routines designed to report system status and configuration details. GetDeviceCapabilities primarily reports the configuration of a device context, e.g. your video driver or a printer driver. This function, however, requires a handle to a device being reported.

GetDC() provides a handle to a specific device; when called with a parameter of zero (0), GetDC() returns a handle to the current device, the screen in this case.

LOGPIXELSX is a constant defined in the Windows API that tells GetDeviceCaps() to return the number of pixels per inch (PPI) that the device can support. Typically, Small Font displays use 96 PPI and Large Fonts use 120 PPI. Thus, the hasLargeFonts() function returns TRUE when the current display uses 120 PPI.

Why is this Important?

When you develop forms and reports using Small Fonts, they can look "weird" (that's a technical term) when displayed on Large Font displays. If you have users complaining about the appearance of your forms and/or reports, check the Display Settings to determine if Large Fonts are enabled. If so, that's why the documents look strange. The pixel density affects the appearance, resulting in overlapping field values, truncated labels, and graphics that do not fit their containers.

If you are encountering this problem, there are three primary strategies available:

  1. Switch the affected displays back to Small Fonts. (This is the cheapest solution, though you may get complaints from your users.)
     
  2. Display a warning to the user and let them decide whether or not to switch the display settings. (Reasonably cheap and lets the user make the decision. May be more diplomatic than the previous strategy.)
     
  3. Design two sets of documents, one for small fonts and the other for large font systems. While this is the most expensive and difficult to maintain solution, it is the most convenient for the users, as it supports their preferences.
Note: When prototyping external DLL's or Windows API functions, remember that the Win32 API is case-sensitive. You must declare the USES prototype using the same case used to export the function in the DLL.

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 31 May 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]