This code allows you to set the margins for a textbox
Simply call SetMargin with the left and right margins, along with the hWnd of the textbox that you want changed. Note that to set the right margin, you need to have align set to right, and vice-versa.
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam
As Long, ByVal lParam As Long) As Long
Private Const EM_SETMARGINS = &HD3
Private Const EC_LEFTMARGIN = &H1
Private Const EC_RIGHTMARGIN = &H2
' Set the TextBox's margins.
Private Sub SetMargin(nLeft As Integer, nRight As Integer, lhWnd As Long)
Dim lLongValue As Long
'nRight needs to be in the hi-word, so we multiply by 65536
lLongValue = 65536 * nRight + nLeft
SendMessage lhWnd, EM_SETMARGINS, _
EC_LEFTMARGIN Or EC_RIGHTMARGIN, lLongValue
End Sub
Comments