Results 1 to 6 of 6

Thread: ListBox row height

  1. #1

    Thread Starter
    Fanatic Member InvisibleDuncan's Avatar
    Join Date
    May 2001
    Location
    Eating jam.
    Posts
    819

    ListBox row height

    Does anyone know of a simple way to calculate the height of a row in a listbox? I'm trying to get my listbox to resize depending on the number of items in it, so that it's always exactly the right height.

    Ta...
    Indecisiveness is the key to flexibility.

    www.mangojacks.com

  2. #2
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    mark one, take a screenshot and measure it in paint?
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
    4.                                                                             ByVal wMsg As Long, _
    5.                                                                             ByVal wParam As Long, _
    6.                                                                             ByVal lParam As Long) _
    7.                                                                             As Long
    8.  
    9. Private Const LB_GETITEMHEIGHT = &H1A1
    10.  
    11. Private Sub Command1_Click()
    12. Dim lHeight As Long
    13.  
    14.     lHeight = SendMessageLong(List1.hwnd, LB_GETITEMHEIGHT, 0&, 0&)
    15.    
    16.     MsgBox lHeight & " pixels in height"
    17.  
    18. End Sub
    19.  
    20. Private Sub Form_Load()
    21.     List1.AddItem "Test"
    22. End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    My method's less icky
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    Originally posted by vbNeo
    My method's less icky
    What happens when he changes fonts? Then another screenshot needs to be taken and all that.

    Poo on you.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Originally posted by crptcblade
    Poo on you.
    Poo isn't icky
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width