Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: 79137913 en 26 Mayo 2011, 15:51 pm



Título: [SOURCE] HListScrollAdd7913 Funcion para agregar Scroll horizontal a un ListBox
Publicado por: 79137913 en 26 Mayo 2011, 15:51 pm
HOLA!!!

Como lo dice el titulo, agrega un scrollbar horizontal al ListBox, yo la usaria con Call, pero le puse para que devolviera false en el caso que no resultara.

Código
  1. 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
  2.  
  3. Private Function HListScroll7913Add(ListX As ListBox) As Boolean
  4. On Error GoTo Err:
  5. Dim X As Long
  6. Dim new_len As Long
  7. Dim max_len As Long
  8.    HListScrollAdd7913 = True
  9.    For X = 0 To ListX.ListCount - 1
  10.        new_len = 10 + ScaleX(TextWidth(ListX.List(X)), ScaleMode, vbPixels)
  11.        If max_len < new_len Then max_len = new_len
  12.    Next
  13.    SendMessage ListX.hwnd, &H194, max_len, 0
  14. Err:
  15.    HListScrollAdd7913 = False
  16. End Function

GRACIAS POR LEER!!!


Título: Re: [SOURCE] HListScrollAdd7913 Funcion para agregar Scroll horizontal a un ListBox
Publicado por: seba123neo en 27 Mayo 2011, 02:11 am
es igual que esto:

Agregar ScrollBar horizontal a un ListBox (http://www.recursosvisualbasic.com.ar/htm/listado-api/182-scrollbar-horizontal-en-listbox.htm)

yo igual declararia la constante que le estas pasando ahi que es "&H194", que corresponde a:

Código
  1. Private Const LB_SETHORIZONTALEXTENT = &H194

porque sino no se sabe que es ese valor....

otra forma es esta:

Código
  1. Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, ByVal bShow As Long) As Long
  2. Private Const SB_HORZ = 0
  3. Private Const SB_VERT = 1
  4. Private Const SB_BOTH = 3
  5.  
  6. Private Sub Form_Load()
  7. ShowScrollBar List1.hwnd, SB_HORZ, True
  8. End Sub

saludos.