home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / vbmbttn2 / vbmbttn.txt < prev    next >
Text File  |  1992-03-14  |  5KB  |  109 lines

  1.  
  2.           Multi-Button Control for Visual Basic by Mark Gamber  1992
  3.  
  4.    The Multi-Button is a single control which divides itself into several small
  5. "sub-buttons", each acting as an independent button in itself. The Multi-Button
  6. may be used for multiple choice entries, array and matrix entries, spreadsheet
  7. headers and so on. Each sub-button may be individually raised or pressed under
  8. software control and the raised and lowered background and text colors may be
  9. changed for an entire control. If you have the original version, this version
  10. far surpasses it's functionality as will be demostrated. To use the button,
  11. copy VBMBTTN.VBX to your Visual Basic directory, select "Add File..." from the
  12. Visual Basic "File" menu and select VBMBTTN.VBX from the list of files. Once
  13. selected, a Multi-Button icon should appear in the toolbox.
  14.  
  15.  
  16. Limitations:
  17.  
  18.    The Multi-Button is capable of dividing into 256 sub-buttons. Should you go
  19. beyond that limit, you will be greeted with a UAE. There is no error checking
  20. provided to ensure you stay within that limit as it could be exceeded by any
  21. combination of things. Therefore, it is up to the programmer to ensure no more
  22. than 256 sub-buttons are displayed by a single Multi-Button.
  23.  
  24.  
  25.  
  26. Events:
  27.  
  28.    Only one event is supported directly by the Multi-Button. "Clicked" provides
  29. the sub-button number and whether the button click raised or lowered the sub-
  30. -button. "Button" always begins with 0 and runs to 255. The actual range to
  31. expect depends on the number of sub-buttons displayed. "Pressed" is 1 if the
  32. sub-button was pressed, 0 if it was raised by the click event.
  33.    GotFocus and LostFocus are supported by Visual Basic. Basically, since the
  34. control cannot use keyboard input, it should never get the focus. In the off
  35. chance that it does, you should use GotFocus to immediately change the input
  36. focus to another control on a form.
  37.  
  38.  
  39.  
  40. Properties:
  41.  
  42.    The Multi-Button numbers it's sub-buttons internally from 0 to 255. You may
  43. change the number DISPLAYED by altering the value in "NumBase". NumBase is
  44. added to the internal sub-button count as the sub-buttons are painted. Thus, if
  45. you want a range from 1 to 10, you would set NumBase to 1 and size the control
  46. so 10 sub-buttons are displayed.
  47.    Numbers aren't the only thing displayed. By selected "True" for the "Alpha"
  48. property, letters may be displayed. In the case of letter labelling, a NumBase
  49. of 0 will cause the first sub-button to display as the letter "A". The sub-
  50. -buttons are incremented from "A" to "Z", "AA" to "AZ", "BA" to "BZ" and so on
  51. up to "ZZ".
  52.    "Width" and "Height" are supported directly by the Multi-Button and are
  53. available in pixel format only. They comprise the width and height of the
  54. entire control. To set or look up the size of a sub-button, use the "SubWidth"
  55. and "SubHeight" properties. They, too, are available only in pixel format.
  56. Note that changing the SubWidth or SubHeight values should be followed by a
  57. change in size to the entire control to prevent partial sub-buttons from
  58. appearing. This is easily accomplished by setting the control size to the
  59. number of sub-buttons to be displayed times the Subsize changed.
  60.    The sub-button background color may be set for both sub-button states. The
  61. default values are light gray for both states. In addition, the text color may
  62. be set for both conditions. Defaults are black if raised, blue if pressed. The
  63. "BackUp" property sets and retrieves the raised color value and "BackDown" sets
  64. and retrieves the pressed color value of the sub-button background. "TextUp"
  65. and "TextDown" perform the same function for the sub-button text. Setting these
  66. properties affects ALL sub-buttons in a given control.
  67.  
  68.  
  69.  
  70. Methods:
  71.  
  72.    Not being very accustomed to Visual Basic terminology, I am not too sure of
  73. the difference between a property and a method but this seems to fall more into
  74. the latter catagory.
  75.    A sub-button may be checked to see if it's raised or pressed. In addition, a
  76. sub-button may be raised or pressed under software control through the "Value"
  77. method. Since there may be up to 256 sub-buttons per Multi-Button, this is an
  78. array, each array part specifying a single sub-button. Pressing a sub-button
  79. consists of setting the Value for a sub-button to a non-zero number and raising
  80. a sub-button consists of setting a sub-button value to zero. Again, the array
  81. ALWAYS starts a ZERO, regardless of the button number displayed which only
  82. reflects the NumBase value. For example, if your Multi-Button is displaying
  83. sub-buttons from 1 to 10 and you want sub-button 1 pressed, you would:
  84.  
  85.    MultiBtn1.Value( 0 ) = 1
  86.  
  87. To see if the same button has been pressed:
  88.  
  89.    if MultiBtn1.Value(0) <> 0 then ...
  90.  
  91.  
  92.  
  93.  
  94. Additional information:
  95.  
  96.    Thanks to PCC David for his suggestions leading to this version of the
  97. control. This is free software given two conditions:
  98.  
  99. 1. Any information pertaining to the author (me) MAY NOT be changed.
  100. 2. I'm not liable. Period.
  101.  
  102.    MBDEMO has been included along with the Visual Basic source for the program
  103. to serve as an example of Multi-Button use. Questions, bugs and complaints are
  104. welcome. E-Mail to PCA MarkG on America Online. No substitutes. I don't take
  105. phone calls, letters or BBS mail.
  106.  
  107.    Mark Gamber  (PCA MarkG)
  108.  
  109.