我在详细信息模式下有一个 VB6 列表视图,显示 X 个项目。我想创建某种自动高度函数,它根据指定的宽度和项目数评估高度。
以下代码不起作用:
Public Declare Function MessageSend Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const LVM_FIRST As Long = &H1000
Public Const LVM_APPROXIMATEVIEWRECT As Long = (LVM_FIRST + 64)
Public Sub GetAutoWidth(lvw as ListView)
result = MakeLPAram(-1, 0)
MessageSend lvw.hWnd, LVM_APPROXIMATEVIEWRECT, -1&, result
lvw.height = loWord(result) * Screen.TwipsPerPixelX
End Sub
Public Function LoWord(value As Long) As Long
LoWord = (value And &HFFFF&)
End Function
Public Function MakeLPAram(wLow As Long, wHigh As Long) As Long
MakeLPAram = MakeLong(wLow, wHigh)
End Function
Public Function MakeLong(wLow As Long, wHigh As Long) As Long
MakeLong = LoWord(wLow) Or (&H10000 * LoWord(wHigh))
End Function
谁能帮我这个?