Me encontre con estas constantes para alinear un
ListBox e hice esta sencilla función, poner en un módulo:
Solo incluyo alineamiento de items a la derecha e izquierda, porque para centrarlos hay que hacerlo de forma diferente. :silbar:
Posteado en http://www.visual-coders.com.ar/
Option Explicit
'=========================================================
' º Function : AlignListBox
' º Author : Mr. Frog ©
' º Mail : vbpsyke1@mixmail.com
' º Recommended Websites :
' http://visual-coders.com.ar
' http://InfrAngeluX.Sytes.Net
' http://twitter.com/#!/PsYkE1
'=========================================================
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_EX_RIGHT As Long = &H1000&
Private Const WS_EX_LEFT As Long = &H0&
Private Const WS_EX_LEFTSCROLLBAR As Long = &H4000&
Private Const WS_EX_RIGHTSCROLLBAR As Long = &H0&
Public Enum AlignConstants
aLeft = 0
aRight = 1
End Enum
Public Enum OptionAlign
Items = 0
ScollBar = 1
End Enum
Public Function AlignListBox(ByVal myListBox As ListBox, _
ByVal ThingToAlign As OptionAlign, _
Optional ByVal Align As AlignConstants = aLeft) As Long
Dim lStyle As Long
Dim lHwnd As Long
If Not (myListBox Is Nothing) Then
lHwnd = myListBox.hwnd
lStyle = GetWindowLong(lHwnd, GWL_EXSTYLE)
If Align = aRight Then
If ThingToAlign = Items Then
lStyle = lStyle Or WS_EX_RIGHT
Else
lStyle = lStyle And WS_EX_RIGHTSCROLLBAR
End If
Else
If ThingToAlign = Items Then
lStyle = lStyle And WS_EX_LEFT
Else
lStyle = lStyle Or WS_EX_LEFTSCROLLBAR
End If
End If
AlignListBox = SetWindowLong(lHwnd, GWL_EXSTYLE, lStyle)
End If
End Function
Ejemplo:
Option Explicit
Private Sub Form_Load()
Dim Q As Long
For Q = 0 To (Screen.FontCount - 1)
List1.AddItem Screen.Fonts(Q)
Next Q
AlignListBox List1, Items, aRight
'AlignListBox List1, Items, aLeft
AlignListBox List1, ScollBar, aLeft
'AlignListBox List1, ScollBar, aRight
End Sub
Resultado:
(http://img31.imageshack.us/img31/5813/dibujomo.jpg)
DoEvents! :P
Gracias por compartir Mr. Frog... Te diste por venisido con mi programa??? :laugh:
De nada... ;)
Ahora estoy acabando una cosa similar de una manera NUNCA vista. :)
Cita de: agus0 en 13 Diciembre 2010, 03:14 AM
Gracias por compartir Mr. Frog... Te diste por venisido con mi programa??? :laugh:
:xD
Ya lo hable con
Dessa, eso solo te pasa a ti, no tengo
W7 para probarlo, en
Wxp ya te dije que me va bien. :silbar:
DoEvents! :P
Cita de: Mr. Frog © en 13 Diciembre 2010, 03:19 AM
De nada... ;)
Ahora estoy acabando una cosa similar de una manera NUNCA vista. :):xD
Ya lo hable con Dessa, eso solo te pasa a ti, no tengo W7 para probarlo, en Wxp ya te dije que me va bien. :silbar:
DoEvents! :P
Como Programador, hay que depurar el Software para todos los Sistemas, ademas, Con mas razón siendo W$7 el que falla, por que es el mas actual Jajaja