按钮控件上的垂直文本 VB
Vertical Text on Button control VB
我在表单上的一个按钮需要像这样显示垂直文本:
S
T
O
P
我发现涉及覆盖 Paint 的解决方案对于这样一个简单的任务来说似乎太复杂了。我试过这个:
Private Sub LabelStopButton()
Dim btTitle As String = "S" & vbCrLf & "T" & vbCrLf & "O" & vbCrLf & "P" & vbCrLf
Me.btnStop.Text = btTitle
End Sub
并尝试将 vbCrLf 替换为:vbCr、vbLf、Environment.NewLine - 无济于事,结果相同:按钮上仅显示第一个字母 "S"。 See image.
使用 Visual Studio 2008(这是一个适用于旧 WinCE 6.0 设备的应用程序)。
有什么建议吗?
谢谢!
这是现有问题的副本
见
参考转换代码:
您需要将按钮设置为允许多行。这可以通过以下 P/Invoke 代码实现。
Private Const BS_MULTILINE As Integer = &H2000
Private Const GWL_STYLE As Integer = -16
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, dwNewLong As Integer) As Integer
End Function
Public Shared Sub MakeButtonMultiline(b As Button)
Dim hwnd As IntPtr = b.Handle
Dim currentStyle As Integer = GetWindowLong(hwnd, GWL_STYLE)
Dim newStyle As Integer = SetWindowLong(hwnd, GWL_STYLE, currentStyle Or BS_MULTILINE)
End Sub
这样使用:
MakeButtonMultiline(button1)
我使用以下代码在按钮上创建了垂直文本:
CommandButton1.Caption = "F" & Chr(10) & "I" & Chr(10) & "L" & Chr(10) & "T" & Chr(10) & "E" & Chr(10) & "R" & Chr(10)
我在表单上的一个按钮需要像这样显示垂直文本:
S
T
O
P
我发现涉及覆盖 Paint 的解决方案对于这样一个简单的任务来说似乎太复杂了。我试过这个:
Private Sub LabelStopButton()
Dim btTitle As String = "S" & vbCrLf & "T" & vbCrLf & "O" & vbCrLf & "P" & vbCrLf
Me.btnStop.Text = btTitle
End Sub
并尝试将 vbCrLf 替换为:vbCr、vbLf、Environment.NewLine - 无济于事,结果相同:按钮上仅显示第一个字母 "S"。 See image.
使用 Visual Studio 2008(这是一个适用于旧 WinCE 6.0 设备的应用程序)。
有什么建议吗? 谢谢!
这是现有问题的副本
见
参考转换代码:
您需要将按钮设置为允许多行。这可以通过以下 P/Invoke 代码实现。
Private Const BS_MULTILINE As Integer = &H2000
Private Const GWL_STYLE As Integer = -16
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer
End Function
<System.Runtime.InteropServices.DllImport("coredll")> _
Private Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, dwNewLong As Integer) As Integer
End Function
Public Shared Sub MakeButtonMultiline(b As Button)
Dim hwnd As IntPtr = b.Handle
Dim currentStyle As Integer = GetWindowLong(hwnd, GWL_STYLE)
Dim newStyle As Integer = SetWindowLong(hwnd, GWL_STYLE, currentStyle Or BS_MULTILINE)
End Sub
这样使用:
MakeButtonMultiline(button1)
我使用以下代码在按钮上创建了垂直文本:
CommandButton1.Caption = "F" & Chr(10) & "I" & Chr(10) & "L" & Chr(10) & "T" & Chr(10) & "E" & Chr(10) & "R" & Chr(10)