|
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 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:
|
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|