詳細モードの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
誰でもこれで私を助けることができますか?