Article ID: 154517
Article Last Modified on 7/13/2004
Option Explicit
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" _
(ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, _
lpRect As RECT, ByVal wFormat As Long) As Long
Private Const DT_BOTTOM = &H8
Private Const DT_CENTER = &H1
Private Const DT_LEFT = &H0
Private Const DT_RIGHT = &H2
Private Const DT_TOP = &H0
Private Const DT_VCENTER = &H4
Private Const DT_WORDBREAK = &H10
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Dim lSuccess As Long
Dim sPrintText As String
Dim MyRect As RECT
Form1.Font.Size = 12
Form1.ScaleMode = vbPixels
MyRect.Left = 0
MyRect.Right = Form1.ScaleWidth
MyRect.Top = 20
MyRect.Bottom = 60
sPrintText = "Print this text"
lSuccess = DrawText(Form1.hdc, sPrintText, Len(sPrintText), _
MyRect, DT_CENTER or DT_WORDBREAK)
End Sub
Global Const DT_TOP = &H00000000 Global Const DT_LEFT = &H00000000 Global Const DT_CENTER = &H00000001 Global Const DT_RIGHT = &H00000002 Global Const DT_VCENTER = &H00000004 Global Const DT_BOTTOM = &H00000008 Global Const DT_WORDBREAK = &H00000010 Global Const DT_SINGLELINE = &H00000020 Global Const DT_EXPANDTABS = &H00000040 Global Const DT_TABSTOP = &H00000080 Global Const DT_NOCLIP = &H00000100 Global Const DT_EXTERNALLEADING = &H00000200 Global Const DT_CALCRECT = &H00000400 Global Const DT_NOPREFIX = &H00000800 Global Const DT_INTERNAL = &H00001000 Global Const DT_EDITCONTROL = &H00002000 Global Const DT_PATH_ELLIPSIS = &H00004000 Global Const DT_END_ELLIPSIS = &H00008000 Global Const DT_MODIFYSTRING = &H00010000 Global Const DT_RTLREADING = &H00020000 Global Const DT_WORD_ELLIPSIS = &H00040000
Keywords: kbhowto kb32bitonly kbprogramming KB154517