、RichTextBox最大の高さと可変幅があります。
スクロールバーを使わずにすべてのテキストを収めるために、ボックスの幅のサイズを変更したいと思います。
それを行う方法はありますか?
コントロールにスクロール バーがあるかどうかを取得するには、次のようにします。
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer
テキストを変更した後、次のような関数を呼び出します。
Private Sub ValidateTextBox(tb As RichTextBox)
Dim Hdl As IntPtr = tb.Handle
Dim Style, VBar As Integer
tb.Width = iMinWidth
Style = GetWindowLong(Hdl, GWL_STYLE)
VBar = Style And WS_VSCROLL
While VBar > 0 AndAlso tb.Width < iMaxWidth
tb.Width += 24
Style = GetWindowLong(Hdl, GWL_STYLE)
VBar = Style And WS_VSCROLL
End While
End Sub
Public Const WS_VSCROLL As Integer = &H200000
Public Const GWL_STYLE As Integer = (-16)