home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
MS_DEV
/
VBCCE
/
SAMPLES
/
Flexlbl
/
FlexLbl.EXE
/
RCDATA
/
CABINET
/
Flexlbl.ctl
< prev
next >
Wrap
Text File
|
1996-10-25
|
7KB
|
226 lines
VERSION 5.00
Begin VB.UserControl FlexLabel
ClientHeight = 660
ClientLeft = 0
ClientTop = 0
ClientWidth = 1500
BeginProperty Font
Name = "Tahoma"
Size = 8.4
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
PropertyPages = "FlexLbl.ctx":0000
ScaleHeight = 660
ScaleWidth = 1500
ToolboxBitmap = "FlexLbl.ctx":0004
Begin VB.Label lblInfo
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 1215
End
End
Attribute VB_Name = "FlexLabel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' FlexLabel Control
' VB Component Team
' Microsoft Corporation
' October 1996
Option Explicit
'Constant for TrueType check
Private Const TMPF_TRUETYPE = &H4
'UDT for TrueType check
Private Type TEXTMETRIC
tmHeight As Long
tmAscent As Long
tmDescent As Long
tmInternalLeading As Long
tmExternalLeading As Long
tmAveCharWidth As Long
tmMaxCharWidth As Long
tmWeight As Long
tmOverhang As Long
tmDigitizedAspectX As Long
tmDigitizedAspectY As Long
tmFirstChar As Byte
tmLastChar As Byte
tmDefaultChar As Byte
tmBreakChar As Byte
tmItalic As Byte
tmUnderlined As Byte
tmStruckOut As Byte
tmPitchAndFamily As Byte
tmCharSet As Byte
End Type
'API declare for TrueType check
Private Declare Function GetTextMetrics Lib "gdi32" Alias "GetTextMetricsA" (ByVal hdc As Long, lpMetrics As TEXTMETRIC) As Long
Enum FlexLabelErr
errNonTrueTypeFont
End Enum
'Default Property Values
Const m_def_Caption = "FlexLabel"
'Property Variables
Dim m_Caption As String
Dim ChangeInProgress As Boolean
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
ChangeInProgress = False
lblInfo.Caption = UserControl.Name
End Sub
Private Sub UserControl_Resize()
If ChangeInProgress = False Then
ChangeInProgress = True
' --- Set height of text to match box
With lblInfo
If TextHeight(.Caption) > Height Then
While (TextHeight(.Caption) > Height)
FontSize = FontSize - 1
Wend
ElseIf TextHeight(.Caption) < Height Then
While (TextHeight(.Caption) < Height)
FontSize = FontSize + 1
Wend
FontSize = FontSize - 1
End If
.FontSize = FontSize
' --- Set width of box to match text
If Len(.Caption) = 0 Then
Width = 100
Else
Width = TextWidth(.Caption)
End If
.Move 0, 0, ScaleWidth, ScaleHeight
End With 'lblInfo
ChangeInProgress = False
End If
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
lblInfo.Caption = PropBag.ReadProperty("Caption", "FlexLabel")
lblInfo.ToolTipText = PropBag.ReadProperty("ToolTipText", "")
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Caption", lblInfo.Caption, "FlexLabel")
Call PropBag.WriteProperty("ToolTipText", lblInfo.ToolTipText, "")
End Sub
Public Property Get Font() As Font
Attribute Font.VB_Description = "Returns a Font object."
Attribute Font.VB_UserMemId = -512
Set Font = lblInfo.Font
End Property
Public Property Set Font(ByVal New_Font As Font)
Dim tmpFont As Font
Set tmpFont = lblInfo.Font
Set UserControl.Font = New_Font
If IsTrueType(UserControl.hdc) Then
' Update control with new font informaton
lblInfo.Font = New_Font
With lblInfo.Font
.Bold = New_Font.Bold
.Italic = New_Font.Italic
.Strikethrough = New_Font.Strikethrough
.Underline = New_Font.Underline
.Weight = New_Font.Weight
End With 'lblInfo.Font
UserControl_Resize
Else
' Report error and reset font
ErrorInfo (errNonTrueTypeFont)
Set UserControl.Font = tmpFont
End If
End Property
Public Property Get Caption() As String
Attribute Caption.VB_Description = "Returns/sets the text displayed in an object's title bar or below an object's icon."
Caption = lblInfo.Caption
End Property
Public Property Let Caption(ByVal New_Caption As String)
lblInfo.Caption = New_Caption
' Update control with new text information
UserControl_Resize
PropertyChanged "Caption"
End Property
Private Function IsTrueType(phDC As Long) As Boolean
Dim lRet As Long
Dim pMETRIC As TEXTMETRIC
lRet = GetTextMetrics(phDC, pMETRIC)
If (pMETRIC.tmPitchAndFamily And TMPF_TRUETYPE) > 0 Then
IsTrueType = True
Else
IsTrueType = False
End If
End Function
Public Sub ErrorInfo(MyErrNumber As FlexLabelErr)
Const ErrLocation As String = "FlexLabel Control"
Dim lStr As String
Select Case MyErrNumber
Case errNonTrueTypeFont
lStr = "An attempt was made to set the control font to a " & _
"non TrueType font. The control font remains unchanged."
If Ambient.UserMode Then
Err.Raise vbObjectError + errNonTrueTypeFont, _
UserControl.Name, lStr
Else
MsgBox lStr, vbOKOnly + vbExclamation, ErrLocation
End If
Case Else
With Err
.Raise .Number, .Source, .Description
End With 'Err
End Select
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=lblInfo,lblInfo,-1,ToolTipText
Public Property Get ToolTipText() As String
Attribute ToolTipText.VB_Description = "Returns/sets the text displayed when the mouse is paused over the control."
ToolTipText = lblInfo.ToolTipText
End Property
Public Property Let ToolTipText(ByVal New_ToolTipText As String)
lblInfo.ToolTipText = New_ToolTipText
PropertyChanged "ToolTipText"
End Property