Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


Click here to copy the following block
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
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) _
  As Long
 
Const LB_RESETCONTENT = &H184
Const LB_GETCOUNT = &H18B
Const LB_GETTEXT = &H189
Const LB_ADDSTRING = &H180
Const LB_GETITEMDATA = &H199
Const LB_SETITEMDATA = &H19A

' Duplicate the contents of a ListBox control to another ListBox control
'
' Pass False to the last argument to append contents
' (the target control isn't cleared before adding elements)
'
' uses API functions for the fastest code

Sub DuplicateListBox(Source As ListBox, Target As ListBox, _
  Optional AppendMode As Boolean)
  Dim index As Long
  Dim itmData As Long
  Dim numItems As Long
  Dim sItemText As String
  
  ' prepare the receiving buffer
  sItemText = Space$(512)
  
  ' temporarily prevent updating
  LockWindowUpdate Target.hWnd
  
  ' reset target contents, if not in append mode
  If Not AppendMode Then
    SendMessage Target.hWnd, LB_RESETCONTENT, 0, ByVal 0&
  End If

  ' get the number of items in the source list
  numItems = SendMessage(Source.hWnd, LB_GETCOUNT, 0&, ByVal 0&)
  
  For index = 0 To numItems - 1
    ' get the item text
    SendMessage Source.hWnd, LB_GETTEXT, index, ByVal sItemText
    ' get the item data
    itmData = SendMessage(Source.hWnd, LB_GETITEMDATA, index, ByVal 0&)
    ' add the item text to the target list
    SendMessage Target.hWnd, LB_ADDSTRING, 0&, ByVal sItemText
    ' add the item data to the target list
    SendMessage Target.hWnd, LB_SETITEMDATA, index, ByVal itmData
  Next
  
  ' allow redrawing
  LockWindowUpdate 0
  
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.