home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / mlist_45 / read.txt < prev    next >
Text File  |  1994-05-04  |  38KB  |  983 lines

  1. ***************************************************************************
  2. *
  3. *  McKean Consulting
  4. *  Robin W. McKean
  5. *  1042 Braddock Circle
  6. *  Woodstock GA  30188
  7. *
  8. *  MLIST.VBX    V4.50.0000
  9. *
  10. *  Multi-Purpose List Box Control for Visual Basic 3.0
  11. *
  12. ***************************************************************************
  13.  
  14. MLIST is a custom control for managing the way your data appears in a list
  15. box.  MLIST is a property for property replacement of the standard List Box
  16. control which comes with Visual Basic 3.0.  In addition, there are many more
  17. features which MLIST can do that you can't do with the normal List Box.  Some
  18. of these features are:
  19.  
  20.     * Set up owner draw columnar data in the list box.  This is NOT a
  21.       MULTI-COLUMN list box.  MLIST now has this feature, but the MLIST
  22.       List Box scrolls vertically, like a normal list box.  Your data is
  23.       arranged in columns, with specific drawing flags setup for each
  24.       "Drawing Region".  Think of each line as being broken up into
  25.       different areas, each with its own drawing flags and data.
  26.  
  27.     * Make a drawing region a bitmap or a checkbox.  You have control
  28.       over the entire list's bitmaps through the default bitmap property,
  29.       or you can set individual lines bitmap properties.
  30.  
  31.     * Control individual line colors in the list box
  32.  
  33.     * Total control over the checked and unchecked states of lines
  34.  
  35.     * Now MLIST has aligned bitmaps as well.  You specifiy the bitmap,
  36.       the text, and the alignment (top, bottom, right, left), and MLIST
  37.       will draw the text and the bitmap in the area you define.
  38.  
  39.     * New in verions 4.00.  You can now have true MUTLIPLE COLUMN list
  40.       boxes, with bitmaps and check boxes.  Multiple columns are set
  41.       up through setting the LBS_MULTICOLUMN style for the list box.
  42.       You control the width of each item.  This attribute differs in
  43.       that each line has a certain width.  So it may take two or more
  44.       columns of items to actually fill a line
  45.  
  46.     * Checking and Selecting a range of line items
  47.  
  48.     * Properties to find closest match and find exact matches in the
  49.       list box.
  50.  
  51.     * Complete control over colors in the list box.  Colors can be
  52.       set for normal lines, individual lines, normal highlight colors,
  53.       and individual highlight colors.
  54.  
  55.     * MList V4.10 now has 3-D effects
  56.  
  57.     * You can now setup vertical and horizontal grids
  58.  
  59.     * Virtual List Boxes.  A notification event is sent when more data
  60.       is required by the application.
  61.  
  62.     * Properties to aide you in drag and drop, including identifying
  63.       which line item was dropped upon, and being able to select
  64.       multiple line items before starting a drag
  65.  
  66.     * New ScrollMessage event for drawing column headers over scrolling
  67.       list boxes
  68.  
  69.     * Handle entire drawing of items in your code
  70.  
  71.     * Set individual fonts for individual lines
  72.  
  73.     * Resort entire lists
  74.     
  75.     * Resize list box to fit windows
  76.         
  77.     * Improved string searching
  78.  
  79.     * Variable height lines in the list box
  80.  
  81. ***************************************************************************
  82.  
  83. This ZIP file contains:
  84.  
  85.     MLIST.VBX         VB version of the MLIST custom control
  86.     PROJECT1.MAK    Sample project file for MLIST
  87.     FORM1.FRM        Form used by the sample project
  88.     READ.ME            This file
  89.     PLUS.BMP        Bitmap used in example
  90.     PAGE.BMP        Ditto
  91.  
  92.     FINDSTR.MAK        FindString and FindStringExact Demo
  93.     FIND1.FRM        Form for FindString Demo
  94.  
  95.     VIRTUAL.MAK        Virtual List Box example
  96.     VIRTUAL.FRM        Form for virtual list box
  97.  
  98.     SCROLL.MAK        Scrolling column header examples
  99.     SCROLL.FRM        Form for scrolling example
  100.  
  101. ***************************************************************************
  102.  
  103. REGISTRATION
  104.  
  105. Time for the sob story.  This Multi-Column List Box is Shareware.  It is
  106. NOT crippled in anyway.  When you download this custom control, you have
  107. the same custom control that I am using in my everyday VB programming.
  108. As a Shareware contributor, I am counting on the honor and moral fiber of
  109. every person who downloads this custom control to do the right thing.  I
  110. have contributed and participated in the Shareware arena for years now.
  111. Your small contribution can make a difference to me and my family...
  112.  
  113. Right now, the maximum string size in the List Box is 2048 characters.  Let me
  114. know if this causes a problem.  I don't anticipate anyone needing to display
  115. more than this number of characters to the screen.
  116.  
  117. If you like and appreciate this custom control...
  118.  
  119.   1)  Small time developers like me, send $10.00 to the address listed above
  120.   2)  Corporate users send $15.00 to the address listed above
  121.   3)  Register in the Compuserve SWREG forum ID 1585
  122.  
  123. Registered users may purchase the source...
  124.  
  125.   Send $40.00 to me at the above address.
  126.   Register in the SWREG Forum Id 2257.
  127.  
  128.   If you register via CompuServe, the source will be e-mailed to you.  Please
  129.   remember, you may not purchase source unless you are a registered user.
  130.  
  131.   This control is written in C++ and has been compiled using both
  132.   Borland C++ 3.1 and Visual C++ 1.5.
  133.  
  134. You may now register this control in the SWREG on Compuserve.  Type GO SWREG.
  135.  
  136. Corporate users should register via mail or register twice in the SWREG
  137. Forum, as many of you have already done.
  138.  
  139. ***************************************************************************
  140.  
  141. WARRANTY
  142.  
  143. The control, as is, works the way that I want it to.  This does not mean
  144. that it will work the way that you want it to.   Along those lines, I
  145. totally disclaim that the control will do anything whatsoever.  This
  146. includes any implied abilities and any WARRANTIES, including those for
  147. SUITABILITY for a particular purpose, MERCHANTIBILITY, and all that other
  148. bull crap.
  149.  
  150. ***************************************************************************
  151.  
  152. PROGRAMMER'S NOTES (or, what I need to know to use this custom control)
  153.  
  154. The Multi-Column List Box is an enhanced List Box control.  The following
  155. is a desciption of each additional control.  What it does, and how to
  156. use it in your own VB programming.  For additional control properties, see
  157. those properties included in the standard list box control.  MLIST now
  158. contains all standard listbox properties.  The ones listed below are additions.
  159.  
  160. ItemHeight
  161.  
  162. This property is responsible for controlling the height of each individual
  163. line item in the list box.  It defaults to 195 Twips, the height of the
  164. font used by the standard list box.  You should adjust this height if you
  165. change the font, font size, etc..
  166.  
  167. I'm not sure whether or not this property will change the height of the lines
  168. after the list box has already been created.  I did not design the list box
  169. control to have the height of the items change dynamically.  Set the height
  170. of this item at design time, and the font, and your list box will be fine.
  171. Experiment with this during run-time if you like, and let me know how it
  172. works out, and how I can make this item work more to your liking.
  173.  
  174. DrawRegions
  175.  
  176. This item determines the number of drawing regions on each line.  This is
  177. basically equivelent to the number of COLUMNS, but this list box will still
  178. scroll like a normal list box.  When setting this property, the control
  179. clears the flags for the draw regions and sets them to left aligned, single
  180. line, and centered vertically.  Consult the Windows API for DrawText to
  181. see what exactly these flags mean.
  182.  
  183. ItemLength
  184.  
  185. This is an indexed property which corresponds to the length of each drawing
  186. region.  If you want a drawing region to be a specific length, set that
  187. drawing region's length to the desired setting in twips.  For example...
  188.  
  189.     MList1.DrawRegions = 2
  190.     MList.ItemLength(1) = 500
  191.     MList.ItemLength(2) = 500
  192.  
  193.     ' Generates an out of index error
  194.     MList1.ItemLength(0) = XXX
  195.     MList1.ItemLength(3) = XXX
  196.  
  197. It is probably a good idea to set the lengths of all drawing regions when you
  198. are changing the defaults.
  199.  
  200. DrawFlags
  201.  
  202. This is an indexed property which corresponds to the flags of each drawing
  203. region.  If you want a drawing region to be drawn in a specific manner, set
  204. that drawing region's flags to the desired settings.  For specific flags,
  205. look up the DrawText API function in the Windows API Reference.  In the
  206. following example, I setup two drawing regions and set the second drawing
  207. region's flags to right justify the text.  In this example, the second
  208. drawing region displays currency values.
  209.  
  210.     Const DT_RIGHT = 2
  211.     Const DT_VCENTER = 4
  212.     Const DT_SINGLELINE = 32
  213.  
  214.     MList1.DrawRegions = 2
  215.     MList1.DrawFlags(2) = DT_RIGHT + DT_VCENTER + DT_SINGLELINE
  216.     MList.ItemLength(1) = 500
  217.     MList.ItemLength(2) = 500
  218.  
  219. If you are planning to include the '&' character in your strings, you
  220. should include the DT_NOPREFIX flag to avoid the underline.  I do NOT
  221. automatically add this flag for you, as I want you to have total control
  222. over the flags.
  223.  
  224. ActiveRegion
  225.  
  226. Setting this property affects the next two properties.  It defines the
  227. DrawingRegion (or index or column) that TextRegion and ListRegion will
  228. return.  Perhaps an example is in order.
  229.  
  230. My list box is divided up into three columns, name, account number, dollar
  231. amount.  I want to get the account number for the currently selected line
  232. as well as the first item...
  233.  
  234.     MList1.ActiveRegion = 2
  235.     aString$ = MList1.TextRegion    ' Gets 2nd column of current text
  236.     bString$ = MList1.ListRegion(0)    ' 2nd column of item at index 0
  237.  
  238. TextRegion
  239.  
  240. This property will return the ActiveRegion in the currently selected text.
  241. See the above "ActiveRegion".  Corresponds to a DrawRegion of the Text property.
  242. These values can also be written to at run time.
  243.  
  244. ListRegion
  245.  
  246. This property will return the ActiveRegion in the item at the specific index.
  247. See the above "ActiveRegion".  Corresponds to a DrawRegion of the List property.
  248. These values can also be written to at run time.
  249.  
  250. DefPicture
  251.  
  252. This is the default bitmap to be displayed in the ImageRegion when a specific
  253. bitmap has not been assigned to that items ItemPicture property.  Please see
  254. the demo on setting your own default picture and ItemPicture properties.
  255.  
  256. ImageType
  257.  
  258. This determines what type of image we are dealing with in our image region.
  259. If this property is set to 0, then the ImageRegion property is ignored and
  260. only text is displayed.  If this image type is valid, then a checkbox or
  261. bitmap/icon is displayed in the ImageRegion.
  262.  
  263. Note that when the image type is set to AlignBitmap, the normal drawing
  264. regions no longer apply.  Anybody got a problem with that???
  265.  
  266. ImageRegion
  267.  
  268. This property specifies which region contains the image region.  This value
  269. should be any number between 1 and the number of DrawRegions.  You may not
  270. set this property to a value of less than zero or greater then DrawRegions.
  271. When setting up your DrawRegions, the following is a good example:
  272.  
  273.     MList1.DrawRegions = 3
  274.     MList1.ImageRegion = 1
  275.  
  276.     MList1.ItemLength(1) = 100        ' Bitmap or Icon is in here
  277.     MList1.ItemLength(2) = 500
  278.     MList1.ItemLength(3) = 750
  279.  
  280.     ' Don't leave a space for the ImageRegion in your strings
  281.     MList1.AddItem "Region2" + Chr$(9) + "Region3"
  282.     MList1.AddItem "Region22" + Chr$(9) + "Region33"
  283.  
  284. The ImageRegion is ignored when calculating the "piece" of text that goes in
  285. that region.
  286.  
  287. Checked
  288.  
  289. This property is very similar to the Selected property.  In a Multi-Column
  290. list box with the ImageType set 2 (CheckBox), this property will return to
  291. you whether or not that line item is checked or not.  For example:
  292.  
  293.     For X% = 0 To MList1.ListCount - 1
  294.  
  295.         If MList1.Checked(X%) Then
  296.             Debug.Print "I am Checked! "; X%
  297.         Else
  298.             Debug.Print "I am not checked! "; X%
  299.         End If
  300.     Next X%
  301.  
  302.     ' Check the first item
  303.     MList1.Checked(0) = True
  304.  
  305. ItemPicture
  306.  
  307. This property is an array of pictures which correspond to the bitmaps for
  308. each line item in the list box.  If this item is not set by you, then
  309. the MList uses the DefPicture property.
  310.  
  311.     ' Change the first items picture in the list box
  312.     MList1.ItemPicture(0) = Image1.Picture
  313.  
  314. ItemForeColor
  315.  
  316. This property is an array of color which correspond to the foreground color
  317. for each line item in the list box.  If this item is not set by you, then
  318. the MList uses the default foreground color property.
  319.  
  320.     ' Change the first items foreground color to white
  321.     MList1.ItemForeColor(0) = RGB(255,255,255)
  322.  
  323. ItemBkColor
  324.  
  325. This property is an array of color which correspond to the background color
  326. for each line item in the list box.  If this item is not set by you, then
  327. the MList uses the default background color property.
  328.  
  329.     ' Change the first items background color to black
  330.     MList1.ItemBkColor(0) = RGB(0,0,0)
  331.  
  332. Alignment
  333.  
  334. This property controls the placement of the bitmap when the image type is
  335. set to 4, AlignBitmap.  See the demo for details, but basically the values
  336. for this property are:
  337.  
  338. 1 - Align the bitmap or icon to the left, centered, then the text, centered
  339.     vertically and left justified.
  340. 2 -    Align the bitmap or on top, centered, then the text, centered
  341.     horizontally and vertically.
  342. 3 - Align the bitmap or icon to the right, centered, then the text, centered
  343.     vertically and left justified.
  344. 4 -    Align the bitmap or icon on bottom, centered, then the text, centered
  345.     horizontally and vertically.
  346.  
  347. Note that when the image type is set to AlignBitmap, the normal drawing
  348. regions no longer apply.  Anybody got a problem with that???
  349.  
  350. MultiColumn
  351.  
  352. This turns the list box into a true multiple column list box.  The list box
  353. will scroll horizontal instead of vertical.  A default item width is provided,
  354. but you, the developer, should override this property.  This property should
  355. be set to true for multi-column, or false (the default) for normal list box
  356. behavior.
  357.  
  358. ItemWidth
  359.  
  360. The property specifies the width of each line in a multiple column list box.
  361. The width is set in Twips.  The normal drawing regions still apply, but I
  362. can't think of a reason why someone would want to divide line items in a
  363. column list box into more columns.
  364.  
  365. FindString
  366.  
  367. Setting this property will cause the list box to search for a string with
  368. the closest match from the current ListIndex.  If one is found, that string
  369. is set to the current ListIndex.  This is useful for moving items through
  370. a list box while typing the string in an edit control, ie.  Search in Help.
  371.  
  372. FindStringExact
  373.  
  374. This property is the same as above, except that it will search for an exact
  375. match.
  376.  
  377. RangeStart
  378.  
  379. This property marks the beginning line item for RangeSelected or RangeChecked.
  380. The offset is 0 based, so the first item is 0.
  381.  
  382. RangeEnd
  383.  
  384. This property marks the ending line item for RangeSelected or RangeChecked.
  385.  
  386. RangeSelected
  387.  
  388. All items in the range RangeStart to RangeEnd are marked as selected in the
  389. list box.  If the list box is not multi-select, then this is ignored.
  390.  
  391.     MList1.RangeStart = 0
  392.     MList1.RangeEnd = 3
  393.     MList1.RangeSelected = True
  394.  
  395. RangeChecked
  396.  
  397. All items in the range RangeStart to RangeEnd are marked as checked in the
  398. list box.
  399.  
  400.     MList1.RangeStart = 0
  401.     MList1.RangeEnd = 3
  402.     MList1.RangeChecked = False
  403.  
  404. SetHzScroll
  405.  
  406. When all is said and done, and you are through setting up your list box, and
  407. your columns extend past the displayable area of the list box, setting this
  408. property to True will cause the MLIST control to add up all of the drawing
  409. regions and add a horizontal scroll bar to the list box if one is neccessary.
  410.  
  411.  
  412. HiliteForeColor,
  413.  
  414. This is the default foreground color to use when a line in the list box is
  415. hilited.  If these colors are set, then the normal colors are ignored, and
  416. the HiliteForeColor is used to draw the text, and HiliteBackColor is used
  417. to draw the background.
  418.  
  419. You may force MList to use the default colors by setting this color equal
  420. HiliteBackColor.
  421.  
  422. HiliteBackColor,
  423.  
  424. This is the default background color to use when a line in the list box is
  425. hilited.  If these colors are set, then the normal colors are ignored, and
  426. the HiliteForeColor is used to draw the text, and HiliteBackColor is used
  427. to draw the background.
  428.  
  429. You may force MList to use the default colors by setting this color equal
  430. HiliteForeColor.
  431.  
  432. ItemHiliteForeColor,
  433.  
  434. This is a property array, which corresponds to each line item in the list box.
  435. Using this property, you can set the foreground and background hilited color
  436. of individual line items.
  437.  
  438.     MList1.ItemHiliteForeColor(0) = RGB(0,0,0)
  439.     MList1.ItemHiliteBackColor(0) = RGB(255,255,255)
  440.  
  441. ItemHiliteBackColor,
  442.  
  443. This is a property array, which corresponds to each line item in the list box.
  444. Using this property, you can set the foreground and background hilited color
  445. of individual line items.
  446.  
  447.     MList1.ItemHiliteForeColor(0) = RGB(0,0,0)
  448.     MList1.ItemHiliteBackColor(0) = RGB(255,255,255)
  449.  
  450. MaskingColor
  451.  
  452. This color is used to mask out colors in your bitmaps when they are included
  453. in your MList Box.  For example, lets say that you know you are not going
  454. to use the color white in your bitmaps or list boxes, so, you can set all the
  455. pixels in your bitmap, which you want to be transparent to white, and the
  456. natural color of the list box will show through your bitmap wherever the color
  457. white is.  Think of this as the transparent color, like in Icons, except you
  458. get to determine what it is.
  459.  
  460. HorizontalGrids
  461.  
  462. Set this property to true, if you want to allow horizontal grid lines to be
  463. drawn on your list box.
  464.  
  465. VerticalGrids
  466.  
  467. Set this property to true, if you want to allow vertical grid lines to be
  468. drawn on your list box.
  469.  
  470. GridStyle
  471.  
  472. This determines what line style is used to draw the grid lines.  This didn't
  473. quite turn out the way I wanted, but experiment if you like, and give me
  474. some suggestions.
  475.  
  476. BorderStyle
  477.  
  478. This property controls the border style of the list box.  Valid values are normal,
  479. raised, and inset.
  480.  
  481. RiseColor
  482.  
  483. This is the color of the rising edge of a 3-D list box.  Default color is white.
  484.  
  485. FallColor
  486.  
  487. This is the color of the falling edge of the 3-D list box.  The default color
  488. is a dark grey color.
  489.  
  490. Version
  491.  
  492. This property was included by me to insure backwards compatibility.  You don't
  493. need to be concerned with its use, as I use it for different things.
  494.  
  495. ExtendedSelect
  496.  
  497. This property will allow multiple select list boxes to be accessed via
  498. extended selection.  This causes the listbox to be created with the
  499. LBS_EXENDEDSEL style.  See the MS-Windows SDK help for more on extended
  500. select.
  501.  
  502. GridColor
  503.  
  504. This property determines the color of the horizontal and vertical grids.
  505. The default color is black.  I prefer light grey.
  506.  
  507. FindDirection
  508.  
  509. This property now determines which direction a FindString and
  510. FindStringExact will search the list.  If set to 0, the search will
  511. begin at the currently active ListIndex and search to the bottom of
  512. the list.  If set to one, MList will begin at the current ListIndex
  513. and search to the top of the list.
  514.  
  515. EnableVirtualMsgs
  516.  
  517. This property enables virtual messages.  Setting this property to True
  518. causes a message to be sent to the VirtualMessage event whenever the
  519. user approaches the beginning or end of the list.  These messages are
  520. sent whether caused by a mouse or keyboard event.  See VirtualMessage
  521. event for details.
  522.  
  523. VirtualMsgZone
  524.  
  525. This property determines when a virtual message event is sent.  This
  526. property indicates then "zone" at the beggining and end of the list
  527. that triggers the event.  For example, setting this property to 100,
  528. would cause a VIRTUAL_END event to be sent to VirtualMessage when the
  529. user got within a 100 lines of the end of the list box, and a
  530. VIRTUAL_BEGIN event when the user gets within 100 lines of the begging
  531. of the list box.  The event is only triggered if the user is heading
  532. towards the respective end of the list box.
  533.  
  534. CheckStyle
  535.  
  536. This property deterines the type of "checkbox" displayed by a checkbox
  537. style MList.  When this property is set to 0, the normal "cross/diagonal"
  538. check box is used.  When set to one, a check mark is placed in the box
  539. instead.
  540.  
  541. CheckColor
  542.  
  543. This property determines the color of the check mark.
  544.  
  545. SortColumn
  546.  
  547. When using the DrawRegions property, this property can be used to determine
  548. which piece of your string determines the sort order.  For example:
  549.  
  550.     MList1.DrawRegions = 2
  551.     MList1.SortColumn = 2
  552.     MList1.AddItem "100" + Chr$(9) + "High"
  553.     Mlist1.AddItem "101" + Chr$(9) + "Critical"
  554.  
  555. This example would sort the list box by priority.  Only strings added after
  556. this property is set will be affected.  If this property is changed after
  557. the strings are added, you will have to remove all the strings and then re-add
  558. them.  I thought about doing this myself, but the issues over preserving
  559. pictures, drawing info, and all that other stuff made it a little more difficult
  560. than I care to tackle at this moment.
  561.  
  562. Setting this property to 0 sorts based on the entire string.
  563.  
  564. SelectMode
  565.  
  566. This property will help you when you want to drag and drop with a mutli-select/
  567. extended select list box.  When using the normal extended select/multi-select
  568. list box, after selecting X number of items, if you select a hilited item with
  569. the mouse, all the other items are de-selected.  This is a problem when trying
  570. to drag and drop multiple items from the list.  Setting this property to 1
  571. (Drag and Drop) causes the left mouse click to "Ignored" when the item begin
  572. selected is already hilited.  This allows the user to start the drag (MouseMove),
  573. and you, the developer, can then set MList1.Drag 1, so dragging can begin.  If the
  574. user releases the drag over the same list box, nothing changes.  If the user moves
  575. over other controls, you will get the appropriate messages.
  576.  
  577. Clicking on a hilited item, and not moving the mouse, then releasing the mouse over
  578. the same spot, will de-select all other items in the list box, except for the one
  579. over which the mouse was released.
  580.  
  581. All in all, this property causes MList to behave like the File Manager program which
  582. comes with Windows.  See the Demo and File Manager for examples of the behavior.
  583.  
  584. ItemX
  585.  
  586. This property is available only at run time.  You may set this property in conjunction
  587. with ItemY to determine which item in the list is currently under mouse events.
  588.  
  589. ItemY
  590.  
  591. This property is available only at run time.  You may set this property in conjunction
  592. with ItemX to determine which item in the list is currently under mouse events.
  593.  
  594. Item
  595.  
  596. This property returns the Index of the string at ItemX and ItemY.  Here is
  597. an example that determines over which item a control was dropped:
  598.  
  599.     Sub MList1_DragDrop (Source As Control, X As Single, Y As Single)
  600.  
  601.         MList1.ItemX = X
  602.         MList1.ItemY = Y
  603.  
  604.         Debug.Print "Control was dropped over item at Index";Str$(MList1.Item)
  605.  
  606.     End Sub
  607.  
  608. This property starts the search at TopIndex, since it assumes that the
  609. item you are looking for is currently displayed in the list box.
  610.  
  611. StringCompare
  612.  
  613. This property determines whether compares are case sensitive or case
  614. insensitive.  This only affects the compare when determining placement
  615. in a Sorted list box.  This does not affect FindString and FindStringExact
  616. properties.
  617.  
  618. Resort
  619.  
  620. Setting this property to 1 causes the list box to resort itself, provided 
  621. of course that it is a sorted list box.  Additionally, the sort may fail 
  622. if there is not enough disk space for resorting.
  623.  
  624. NoIntegralHeight
  625.  
  626. Set this property to True if you want to be able to size the list box to fit
  627. inside the entire window.  Normal Windows forces the list box to be an exact
  628. fit for the height of each line item.  For example:  If you have room for ten
  629. line items, and each line item is 195 twips high, Windows will resize the list
  630. box to 1950 even if you tell it to set the list box to 2015.
  631.  
  632. DisableDrawing
  633.  
  634. I added this property to enable the developer to suspend drawing until font
  635. changes, position changes, etc. are completed.  For example, you might want
  636. to set this property to True while you are changing the font characteristics
  637. of a line that is visible in the list box.  Before you set the last font
  638. attribute, set this value to False, and the line will redisplay itself with
  639. the correct font.
  640.  
  641. ItemFontBold
  642.  
  643. This property controls the bold attribute of an individual line item.  Set this
  644. property to true to cause that lines text to be displayed in bold.  A word of
  645. caution...  Setting the individual font attributes of each line will cause a
  646. font for that line to be created.  Windows will only support so many fonts.
  647. If you are going to be setting individual fonts, consider using the UNIMPLEMENTED
  648. property which will accept an actual font handle.  See UNIMPLENTED for details.
  649.  
  650.     MList1.ItemFontBold = True
  651.  
  652. ** You should set the font name before setting this property. **
  653.  
  654. ItemFontItalic
  655.  
  656. This property controls the italicized property of the font for a specific line.
  657. If you want a lines text to appear italicized, set this property to true for
  658. a specific line.
  659.  
  660.     MList1.ItemFontItalic = True
  661.  
  662. ** You should set the font name before setting this property. **
  663.  
  664. ItemFontName
  665.  
  666. This property controls the font name for a specific line of text.  You should
  667. set this property first and then set the others.  See your VB Help for details
  668. on this property "FontName".
  669.  
  670.     MList1.FontName = "MS Sans Serif"
  671.  
  672. ItemFontSize
  673.  
  674. This property controls the individual size for a specific line of text.
  675.  
  676.     MList1.ItemFontSize = 7.8
  677.  
  678. ** You should set the font name before setting this property. **
  679.  
  680. ItemFontStrikeThru
  681.  
  682. Set this property to True if you want the font for a particular line of
  683. text to have a line through it.
  684.  
  685.     MList1.ItemFontStrikeThru = True
  686.  
  687. ** You should set the font name before setting this property. **
  688.  
  689. ItemFontUnderline
  690.  
  691. Set this property to True if you want the font for a particular line of
  692. text to have an underline beneath it.
  693.  
  694.     MList1.ItemFontUnderline = True
  695.  
  696. ** You should set the font name before setting this property. **
  697.  
  698. OwnerDraw
  699.  
  700. Set this property to True if you want to control all drawing of a line.
  701. See the DrawItem event for handling drawing of a line.
  702.  
  703. ListBoxStyle
  704.  
  705. This property determines whether the lines in a list box are a fixed
  706. height or a variable height.  Setting this property to 0 means all the
  707. lines in the list box are a fixed height, as determined by the
  708. ItemHeight property.  If this property is set to 1, then the lines in
  709. the list box are variable height.  The property AddItemHeight should
  710. be set before adding an item to the list.  After that, you can use
  711. IndItemHeight to adjust the height of a line.  The reason for this is
  712. because I need the height of the line before the line is displayed,
  713. otherwise, the entire list must be redrawn when you change the height
  714. of that line with IndItemHeight.
  715.  
  716. AddItemHeight
  717.  
  718. This property determines the height of the next line to be added when
  719. the list is a variable height list box.  See ListBoxStyle above.
  720.  
  721.     MList1.AddItemHeight = 195        ' Default line height
  722.  
  723. IndItemHeight
  724.  
  725. This property can be used to adjust the height of a line item after
  726. it has been added to the list box.  Be aware that this causes the
  727. entire list box to be redrawn.  You might want to disable redrawing
  728. while you adjust he height of a lot of lines.
  729.  
  730.     MList1.IndItemHeight(0) = 395
  731.     MList1.IndItemHeight(2) = 595
  732.  
  733. InString
  734.  
  735. Like FindString, except this property looks for a string in a string.
  736.  
  737. FindColumn
  738.  
  739. Set this propery to the column you want to search when using the 
  740. FindColumnString property.
  741.  
  742. FindColumnString
  743.  
  744. The string you want to search for in FindColumn.
  745.  
  746. FindResult
  747.  
  748. This property controls the action of MList after it finds a string via
  749. FindString, FindStringExact, FindColumnString, or InString.  If set to
  750. 0, then ListIndex is updated, and the image of the list box is updated
  751. as well.  If set to one, the list box is not updated.  In either case,
  752. FindIndex is updated with the ListIndex of the found item, when an item
  753. is successfully found.
  754.  
  755. FindIndex
  756.  
  757. This property contains the ListIndex of the last successful find of an
  758. item.  This property is updated whether FindResult is set to Update List
  759. Index or or Update FindIndex.  Compare this to ListIndex or previously
  760. set FindIndex to see if a find is successful.
  761.  
  762. ***************************************************************************
  763.  
  764. New Events
  765.  
  766. SelChange()
  767.  
  768. This event is called whenever a selection in the list box is changed
  769. either through the keyboard or the mouse.  You might want to use the
  770. event instead of or in addition to the Click method if you want to
  771. respond to selection changes when the user use the arrow keys instead
  772. of the mouse.
  773.  
  774. SelCheck(Index As Integer, State As Integer)
  775.  
  776. This event is called whenever the checked status of a line in the list
  777. box is changed.  The first parameter to this event is the Index
  778. (line item) that has been effected.  The second parameter is the state
  779. of the checked box.  It is either True or False.
  780.  
  781. VirtualMessage(Message As Integer)
  782.  
  783. This is my first attempt at a virtual list box, so please don't laugh.
  784. I am basically providing the means by which to notify you when more
  785. data is needed.  For now, you will have to keep track of your own data.
  786.  
  787. The following Message(s) are sent to this event:
  788.  
  789.  
  790.     VIRTUAL_UP  - This should be defined as having a value of (1).  This
  791.     message will be sent when you need to add items to the end of the
  792.     list, because it is scrolling up.
  793.  
  794.     VIRTUAL_DOWN - This should be defined as having a value of (2).  This
  795.     message will be sent when you need to add items to the beginning of
  796.     the list, because it is scrolling down.
  797.  
  798.     VIRTUAL_END    - This is sent when the user is moving to the end of the
  799.     list.  You should load whatever number of lines you need to, then
  800.     MList will position ListIndex to the end of the list.  This item should
  801.     be defined as (3).
  802.  
  803.     VIRTUAL_HOME - This is sent when the user is moving to the beginning of
  804.     the list.  You should load whatever number of lines you need to, then
  805.     MList will position ListIndex to the start of the list.  This item should
  806.     be defined as (4).
  807.  
  808. MList will move the current ListIndex as Items are added to and removed from
  809. the list.  You should try to cache all the items you will load in memory, then
  810. add them to the list at one time.  Save off TopIndex and ListIndex, so that
  811. you can restore them.  You will need to subtract or add the number of new
  812. items loaded (and removed) depending on which direction you are moving in.
  813. See the example for details.
  814.  
  815. There are no properties like VirtualListIndex, VirtualTopIndex, VirtualCount,
  816. etc.  I am thinking hard about these, and hope to come up with an elegant
  817. solution.  Any suggestions???
  818.  
  819. I guess what I have done is provide virtual capabilities while leaving most
  820. of the implementation in your court.
  821.  
  822. ScrollMessage(Offset As Index)
  823.  
  824. This function is called when the list box is scrolling **HORIZONTALLY**.
  825. This allows you to scroll your own column headers over the list box.  
  826. Offset is the number of **PIXELS** the window has been scrolled.  See
  827. the scroll demo for details.
  828.  
  829. Unforunately, due to Twips To Pixels and vis a vis, there is no exact
  830. relation between the number of pixels and the number of twips.  If you
  831. look at the example, you'll see that the more columns the right you go,
  832. the further off the column header is.  This can be solved manually placing
  833. each one to start with.  Once this is done, just copy the code and go!
  834.  
  835. DrawItem(ListIndex As Integer, ItemAction As Integer, ItemState As Integer, 
  836.             ItemDC As Integer, ItemLeft As Integer, ItemTop As Integer, 
  837.             ItemRight As Integer, ItemBottom As Integer, ItemText As String)
  838.  
  839. This event is called when OwnerDraw is set to True.  Owner draw basically
  840. forces you be responsible for drawing each and every line item.  The
  841. following is a brief description of the parameters.  Lookup Help for
  842. DRAWITEMSTRUCT in your WinAPI help for more details.
  843.  
  844.     ListIndex        - Index of item being drawn.  0 based.
  845.     ItemAction        - Action being performed (See DRAWITEMSTRUCT)
  846.     ItemState        - State of line (See DRAWITEMSTRUCT)
  847.     ItemDC            - DC to do the drawing with.  DON'T use MList1.hDC
  848.     ItemLeft        - Left coordinate of rectangle
  849.     ItemTop         - Top coordinate of rectangle
  850.     ItemRight        - Right coordinate of rectangle
  851.     ItemBottom        - Bottom coordinate of rectange
  852.     ItemText        - The text that needs to be drawn
  853.  
  854. See the commented out code in SCROLL.MAK for details on how you might
  855. get started ousing this feature (Set OwnerDraw to True!).
  856.  
  857. ***************************************************************************
  858.  
  859. FORMATTING STRINGS
  860.  
  861. You should place the Tab character between each column in your string.  The
  862. following example formats a string for the DrawFlags example:
  863.  
  864.     MList1.AddItem "Robin W. McKean" + Chr$(9) + "$100.00"
  865.  
  866. The following string is for three columns:
  867.  
  868.     MList1.AddItem "Robin W. McKean"+Chr$(9)+"$100.00"+Chr$(9)+"True"
  869.  
  870. Remember, you do NOT have to include a column for the ImageRegion.  If
  871. the ImageRegion property was 1 and the DrawRegions property was 3, then
  872. the following line would work fine (3-1=2)
  873.  
  874.     MList1.AddItem "Robin W. McKean"+Chr$(9)+"$100.00"
  875.  
  876. ***************************************************************************
  877.  
  878. REACHING THE AUTHOR
  879.  
  880. I can be reached via U.S. Mail at the address listed above.  You can reach
  881. me via E-Mail at the following locations...
  882.  
  883. Compuserve:            Robin W. McKean
  884.                     72622,1403
  885.  
  886. Shareware South:    Robin W. McKean
  887.                     Atlanta, GA
  888.  
  889. I'm on CompuServe once or twice a day.  I check Shareware South about once
  890. a week.
  891.  
  892. ***************************************************************************
  893.  
  894. REVISION HISTORY
  895.  
  896. 3.00.0000    Initial release of the MLIST.VBX Custom Control
  897. 3.01.0000    Fixed "Bad Index" error message when setting Selected
  898.             property to True|False.
  899.             Added ItemData property to control.
  900.             Added ListIndex property to control.
  901.             Fixed an apparent bug in the VB API that was passing right
  902.             mouse button clicks to the Click event, but not the left
  903.             mouse button.
  904. 3.02.0000    Fixed a ton of problems.  Namely, the page down didn't work.
  905.             Delete current controls and rebuild to fix this problem.
  906.             Added ALL default controls for the standard list box.
  907.             Tested all of them before uploading.
  908. 3.03.0000    Fixed the index problem with the List property.  If anything,
  909.             I am guilty of being over enthusiastic.  I apologize to those
  910.             who got the previous version and thought it sucked.  Probably
  911.             because it did.  I added bitmaps and checkboxes as well as
  912.             the ability to change the color of a specific line.  You can
  913.             also change the bitmap of a specific line item.
  914. 3.04.0000    Fixed the bug with setting the Checked property, and then not
  915.             having the user be able to double click it or click the box
  916.             to change it back.  Added the AlignBitmap image type and
  917.             the Alignment property.
  918. 4.00.0000    Added the Multicolumn property and item width.  Added the
  919.             FindString and FindStringExact properties for searching
  920.             the list box.  Added the range properties for checking
  921.             and selecting multiple line items.
  922. 4.01.0000    Removed the 64k limit.  MLIST will now allow more than 64k
  923.             worth of data to be added to it.  Also, quit handling default
  924.             methods, such as Move (which didn't work), Refresh, and others.
  925.             Fixed problem with RemoveItem not deleting lines data.
  926.             Changing the way MLIST handled strings did the job.
  927. 4.02.0000    Removed a bug which caused a GP fault when more than 16 drawing
  928.             regions were requested by the user.  Reworked VB2.0 compatibility
  929.             strategy.
  930. 4.10.0000    Added 3-D, rise and fall colors, and SelChange event.
  931. 4.11.0000    Hilighted lines will default to the system colors as controlled
  932.             by the control panel.  User may still override useing the
  933.             HiliteForeColor and HiliteBackColor.  Added the ExtendedSelect
  934.             property.
  935. 4.20.0000    Tightened up the difference between a multi-select list box
  936.             and a normal list box.  I added grid color, virtual messages,
  937.             check marks in check boxes, SelChange events when ListIndex is
  938.             changed, SelCheck for when an item is checked/unchecked.
  939. 4.30.0000    Changed the way that virtual list boxes determine when they are
  940.             in the virtual region.  I used to use the TopIndex property,
  941.             now I use the thumb position on the scroll bar.
  942.             Added new properties for SortColumn and StringCompare.  These
  943.             properties allow you sort on different columns as well as
  944.             determine if the strings are case sensitive/insensitive.
  945.             Added new properties for Drag and Drop.  The first, SelectedMode,
  946.             doesn't allow items to become "de-selected" when dragging.  ItemX,
  947.             ItemY, and Item help you determine which line item is being
  948.             dragged over/dropped upon.  Fixed dynamic loading of an MList, and
  949.             calling AddItem "MyString", 0 when there are no items in the list.
  950.             Added ScrollMessage for scrolling column headers.
  951.  
  952. 4.50.0000    Added font support, complete owner draw, disable drawing, and
  953.             NoIntegralHeight support.  Added InString, FindResult,
  954.             FindColumn, and FindColumnString.  Added icon support.
  955.  
  956. ***************************************************************************
  957.  
  958. ACKNOWLEDGEMENTS
  959.  
  960. I would like to thank Simon, Kevin, and Neil for their input.  A great C++
  961. programmer does not a good VB programmer make...  Please, Please, Please,
  962. take a few minutes to notify me if there are any bugs.  I hate bugs...
  963.  
  964. Thanks to Paul for the check box problem.
  965.  
  966. Thanks to Alex for providing info on VB 2.0 problems.
  967.  
  968. Thanks to Michael and David for color problems with hilighted text.
  969.  
  970. Thanks to Michael for extended select reminder.
  971.  
  972. Thanks to Stacy, Juha, Darren and Paul, who all made a big difference in
  973. the quality of this release.
  974.  
  975. Thanks to Robert, for the ideas on improving Drag and Drop and the 
  976. scrolling column header suggestions.
  977.  
  978. Thanks to Alexander for the Load problem.
  979.  
  980. Robert, you're a stud.  Thanks for pointing out the path to font control!
  981.  
  982. ***************************************************************************
  983.