让LISTBOX中内容垂直居中。。
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_USER = &H400
Private Const LB_GETITEMHEIGHT = (WM_USER + 34)
Private Const LB_SETITEMHEIGHT = &H1A0
Private Const WM_SETREDRAW = &HB
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 5
List1.AddItem "演示 " + Format(i)
Next
i = SendMessage((List1.hwnd), LB_GETITEMHEIGHT, 0, &O0)
i = i + 30
i = SendMessage((List1.hwnd), LB_SETITEMHEIGHT, 0, ByVal i)
i = SendMessage((List1.hwnd), WM_SETREDRAW, True, 0&)
End Sub
以上代码实现了LISTBOX高度修改,现在的问题是,那个消息能让字体垂直居中。
[解决办法]
...
最简单的办法就是用一个只有一列的MSHFLEXGRID, 搞定.