Welcome to the premier issue of Code of the Week for Visual Basic. You have found what promises to be the best source code resource for your Visual Basic development.
The source code in this issue is designed for Visual Basic 4.0 16-bit. Similiar code can be implemented in the 32-bit versions of VB. Only the module declarations for the API call should need to be changed. If you are interested in seeing this code, please contact us at http://www.codeoftheweek.com/feedback.html
In this issue we are going to introduce a object class called cListBoxDragDrop. You can use this class to allow your end-users to rearrange the data in a standard Windows list box.
Add drag and drop rearranging/sorting to a standard Windows list box. There are several important methods in the class.
To use this example, create a new project in Visual Basic 4.0 16-bit and drop a list box on a form. Change the Name property of the list box to lstWords. Paste the following code into the declarations section of the form.
Option Explicit Dim oListDrag As New cListBoxDragDrop Private Sub Form_Load() Set oListDrag.FormObj = Me Set oListDrag.ListBoxObj = lstWords End Sub Private Sub lstWords_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single) ' Traps the Mouse Down event which will start ' the dragging operation. oListDrag.MouseDown End Sub Private Sub lstWords_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single) ' Traps the MouseUp event which will end ' the dragging operation. oListDrag.MouseUp End Sub Private Sub lstWords_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single) ' Traps the MouseMove event which will show the ' item in the list being dragged around. oListDrag.DoDragDrop x, Y End Sub
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0001.html
That concludes our first issue of COTW. We hope you find the source code useful in your development.
The below describes the ways you can supply us some feedback about COTW. We would like to see our members help mold COTW into the best Visual Basic source code resource available. But to do that we need your feedback about what you like and what you do not like.
If you have any suggestions for topics you would like to see covered in COTW, please email them to firstname.lastname@example.org or use online feedback form at http://www.codeoftheweek.com/feedback.html.
If you have any source code you would like to submit for possible inclusion in COTW, please fill out our online submission form at http://www.codeoftheweek.com/submission.html.
If you have received this issue in a free offer, please check out http://www.codeoftheweek.com to order your own subscription to COTW. For a limited time you can get 52 issues of COTW for only $19.95. This is a full year of Visual Basic source code and information to help with all your development. So don't wait, subscribe now!