|
home
Small Fonts, Pixel & Twips
Multimedia meets databse. Normally we use an authoring system for
the cartoons (Intro and Extro). That works pixel oriented and does not
look like our normally fashioned Windows window. It's easy to tell VB not
to use title and so on and it's easy to position the VB window exactly
like the pixel map in the background. Nobody will recognize that tools
have changed.
One little problem was to be solved, when we started a video sequence
in a third window at a given position. Now we have three windows, one on
top of the other. Any of the windows use its own optimized color palette.
Sure - we had problems with palette shifting and we had to hide the window
in the middle of the stack while playing the video. So we used the function GetScreenColors
testing for palette size.
The function TestForSmallFonts (thanks 2 MSDN for
GetDeviceCaps) was the result after looking for the error in graphic
configuration and drivers on a test system. Most of the multimedia
programs wont work if you use other fonts than small fonts. The reason is:
they are mostly created using pixel oriented authoring systems. If you
want to use real Windows objects, Twips and therefore so called logical
lengths on printouts are our sizes to handle. Changing small fonts to
other settings is changing logical lengths. This is, a text object
displayed on systems with 640 x 480, small fonts has the same real size as
with 800 x 600 and large fonts.
I don't like CDs that ask me for restarting the system (you had to in
former times when changing screen settings) we looked for a solution. LPX
and LPY from TestForSmallFonts give us
the number to resize pixel or twips oriented objects.
Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, _ ByVal nIndex As Integer) As Integer Declare Function CreateDC Lib "GDI" (ByVal lpDriverName As String, _ ByVal lpDeviceName As String, ByVal lpOutput As String, _ ByVal lpInitData As Any) As Integer Declare Function DeleteDC Lib "GDI" (ByVal hDC As Integer) As Integer
Const BitsPixel = 12 Const Planes = 14 Public Const HORZRES = 8 ' Horizontal width in pixels Public Const VERTRES = 10 ' Vertical width in pixels Public Const VERTSIZE = 6 ' Vertical size in millimeters Public Const HORZSIZE = 4 ' Horizontal size in millimeters Public Const LOGPIXELSX = 88 ' Logical pixels/inch in X Public Const LOGPIXELSY = 90 ' Logical pixels/inch in Y
Public Function TestForSmallFonts() As Boolean
Dim NumWidth As Integer
Dim hDC As Integer
Dim X As Integer
Dim LPX, LPY As Integer
hDC = CreateDC("DISPLAY", "", "", "")
LPX = GetDeviceCaps(hDC, LOGPIXELSX)
LPY = GetDeviceCaps(hDC, LOGPIXELSY)
X = DeleteDC(hDC)
If LPX = 96 And LPY = 96 Then
TestForSmallFonts = True
Else
TestForSmallFonts = False
End If
End Function
Public Function GetScreenColors() As Long
Dim NumColors As Long
Dim hDC As Integer
Dim X As Integer
Dim PL As Integer
Dim BP As Integer
hDC = CreateDC("DISPLAY", "", "","")
PL = GetDeviceCaps(hDC, Planes)
BP = GetDeviceCaps(hDC,BitsPixel)
NumColors = CLng(PL * BP)
X = DeleteDC(hDC)
GetScreenColors = NumColors
End Function
top
|