Areas of Interest, as counted by my cat

Month: December 2005

Windows Vista – first impressions

Ugly.

And the networking doesn’t work. Yet it wants to go out to the Internet for everything.

Oh, and did I say it was butt-ugly? Apparently all the talented UI designers have left Microsoft. I curse the day some idiot decided that dialog boxes and web pages with hyperlinks deserved to merge into some kind of mutant hybrid UI. Consistency, people! Standards! Have you forgotten all that you learned? Why do you think the Win95 interface is cloned and duplicated so fervently by the Linux shell people?

[Update: We got the Vista connected to the network, finally, by selecting a different Ethernet card driver. Vista’s preference was for one that didn’t work.]

FONTMETRIC(), TXTWIDTH(), and screen DPI in Windows

If you are trying to size objects on a VFP form to match a specific font, you have to take into account the current screen DPI setting as well. Consider sizing a Rectangle object to surround a given piece of text. You know the fontname, fontsize, and the actual text string, but you don’t know the dimensions. No problem, you say, I’ll just use FONTMETRIC() and TXTWIDTH() to figure out the size of the text in pixels:

iAvgCharWidth = FONTMETRIC(6, cFontName, cFontSize, "" )
iTextWidth = TXTWIDTH( cString, cFontName, cFontSize, "" ) * iAvgCharWidth

…and now I can size my Rectangle appropriately, you say.

Not so fast. What if your Windows display is set to 120 DPI? The text will be sized differently. You have to take this into account:

*---------------------------------
* Determine the screen DPI:
*---------------------------------
#define LOGPIXELSX 88

declare integer GetDeviceCaps in WIN32API integer HDC, integer item
declare integer GetDC         in WIN32API integer hWnd
*declare integer DeleteDC      in WIN32API integer HDC
declare integer ReleaseDC     in WIN32API integer hWnd, integer HDC

local hdc, screenDPI
hdc    = GetDC(0)
THIS.screenDPI = GetDeviceCaps( m.hdc, LOGPIXELSX )
ReleaseDC( 0, m.hdc )

IF iScreenDPI <> 96
   iTextWidth = INT( (iTextWidth * iScreenDPI)/96 )
ENDIF

I was grappling with issue recently, dealing with a bug reported by someone who said that Pageframe text captions were getting truncated when they set their environment to 120DPI + “Large Fonts”.

Well, this morning I have read a post by the remarkable Charles Petzold about Device Independent Units (DIU) that goes some way (and more) to explaining why we have to do it, because I believe that Visual FoxPro uses actual pixels rather than DIU. His post his worth a read.

© 2024 More Than Four

Theme by Anders NorenUp ↑