Available in the LEADTOOLS Imaging toolkit. |
Font example for Access 2.0
This example, in a MouseUp event, determines the size of a rectangle for a string in the specified font. It then draws the rectangle and draws the text on top of the rectangle.
Sub Lead1_MouseUp (Button As Integer, Shift As Integer, x As Long, y As Long)
Dim TestText As String
Dim gTextWidth As Single
Dim gTextHeight As Single
'Specify the text, font, and styles
TestText = "This is my text."
Me![LEAD1].Object.Font.Name = "Times New Roman"
Me![LEAD1].Object.Font.Size = 16
Me![LEAD1].Object.DrawFontColor = RGB(0, 0, 255) 'Blue
'Use the same scalemode as the mouse.
Me![LEAD1].Object.ScaleMode = 1
'Get the width and height of the text to be drawn.
gTextWidth = Me![LEAD1].Object.DrawTextWidth(TestText)
gTextHeight = Me![LEAD1].Object.DrawTextHeight(TestText)
'Set the properties for drawing a rectangle behind the text.
Me![LEAD1].Object.DrawPenStyle = DRAWPENSTYLE_SOLID
Me![LEAD1].Object.DrawMode = DRAWMODE_COPY_PEN
Me![LEAD1].Object.DrawFillColor = RGB(0, 255, 0) 'Green
'Draw on the screen, not on the bitmap.
Me![LEAD1].Object.DrawPersistence = False
'Draw the rectangle, then draw the text.
Me![LEAD1].Object.DrawRectangle x, y, gTextWidth, gTextHeight
Me![LEAD2].Object.DrawTextOut x, y, TestText
End Sub