home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / design / tbar / readme.txt < prev    next >
Encoding:
Text File  |  1994-08-30  |  20.5 KB  |  555 lines

  1. ***************************************************************************
  2. *
  3. *  McKean Consulting
  4. *  Robin W. McKean
  5. *  1042 Braddock Circle
  6. *  Woodstock GA  30188
  7. *
  8. *  TBAR.VBX    V2.40.0000
  9. *
  10. *  Toolbar Custom Control for Visual Basic 3.0
  11. *
  12. ***************************************************************************
  13.  
  14. TBAR is a custom control for implementing industry standard toolbars in
  15. Visual Basic.  TBAR uses one bitmap, created by the developer, to display
  16. all buttons, in all button states.  One bitmap means faster loading and
  17. fewer system resources.  Additionally, you can design, define, and
  18. implement the behavior of your toolbar without writing a single line of
  19. code!  No longer do you have to be envious of Visual C++ or write your
  20. own code to implement toolbars.  TBAR will do everything for you.  Here
  21. are some features:
  22.  
  23.     * One bitmap defines all buttons, and all button states
  24.  
  25.     * All standard button types allowed, push, toggle, disabled, enabled
  26.  
  27.     * Group buttons.  When one is toggled, the others become untoggled
  28.  
  29.     * Pop up help for each button as seen in industry standard
  30.       applications
  31.  
  32.     * New in version 2.30 vertical and horizontal toolbars with wrapping
  33.  
  34.  * New in version 2.40 On-line help thanks to Kevin Klasman
  35.  
  36.     * And more
  37.  
  38. ***************************************************************************
  39.  
  40. This ZIP file contains:
  41.  
  42.     TBAR.VBX         VB version of the TBAR custom control
  43.     PROJECT1.MAK    Sample project file for TBAR
  44.     MDIFORM1.FRM    Sample MDI form with toolbar
  45.     MDIFORM1.FRX    File used by VB for MDIFORM1
  46.     FORM1.FRM        Form with some simple information
  47.     FORM2.FRM        Form with wrapping toolbar
  48.     READ.ME            This file
  49.     TOOLBAR.BMP        Bitmap of toolbar utilized by the sample
  50.  
  51. ***************************************************************************
  52.  
  53. REGISTRATION
  54.  
  55. If you like and appreciate this custom control...
  56.  
  57.   1)  Small time developers like me, send $25.00 to the address listed above
  58.   2)  Corporate users send $25.00 to the address listed above
  59.   3)  Register in the CompuServe SWREG Forum ID 1700 for $20.00
  60.  
  61. Registered users may purchase the source...
  62.  
  63.   Send $45.00 to me at the above address.
  64.   Register in the SWREG Id 2258.
  65.  
  66.   This control is written in C++ and has been compiled using both
  67.   Borland C++ 3.1 and Visual C++ 1.5.
  68.  
  69. You may now register this control in the SWREG on Compuserve.  Type GO SWREG.
  70.  
  71. Corporate users should register via mail.  Alternatively, you may register
  72. in SWREG by registering two copies, as many of you already have!
  73.  
  74. ***************************************************************************
  75.  
  76. WARRANTY
  77.  
  78. The control, as is, works the way that I want it to.  This does not mean
  79. that it will work the way that you want it to.   Along those lines, I
  80. totally disclaim that the control will do anything whatsoever.  This
  81. includes any implied abilities and any WARRANTIES, including those for
  82. SUITABILITY for a particular purpose, MERCHANTIBILITY, and all that other
  83. bull crap.
  84.  
  85. ***************************************************************************
  86.  
  87. PROGRAMMER'S NOTES (or, what I need to know to use this custom control)
  88.  
  89. The properties for this control can be broken down into two areas.  The
  90. first are properties which apply to the whole toolbar, and properties
  91. which apply to individual buttons.  Individual button properties will
  92. change as you change the currentButton property, or, as you select a
  93. button on the screen, during design, with the right mouse button.
  94.  
  95. The final section will cover the events provided by the Toolbar.
  96.  
  97. TOOLBAR PROPERTIES
  98.  
  99. Outline
  100.  
  101. This property determines whether or not their is a solid line separating
  102. the toolbar from its parent window.  Most standard toolbars have a solid
  103. line of some sort to emphasize the toolbar.  When the toolbar is aligned
  104. top, then there is a line at the bottom.  When the toolbar is aligned
  105. bottom, there is a line at the top.  When there is no alignment, than
  106. this property draws a border around the toolbar.
  107.  
  108. OutlineColor
  109.  
  110. This is the color of the toolbar outline.  It's default is black.
  111.  
  112. Interval
  113.  
  114. This property represents the amount of space, in pixels, between the
  115. buttons in the toolbar.  If you want all buttons to have a little
  116. space between them, set this property to 2.  If you want more distinct
  117. button borders, set this property to one.  The demo has this property
  118. set to 0.
  119.  
  120. ButtonWidth
  121.  
  122. This property tells TBAR how wide, in pixels, each button is in your BITMAP.
  123. TBAR will add 8 pixels to this value to determine the true button size.  As
  124. you design your bitmap for your toolbar, you should decide beforehand what
  125. each button bitmap size will be.  The demo bitmap is 16 pixels wide by 15
  126. pixels high.  There are ten buttons, so the bitmap is 160 pixels wide.  Some
  127. resource editors allow you to break up your bitmap into grids, some don't.
  128. You could use PaintBrush to edit your bitmaps.
  129.  
  130. ButtonHeight
  131.  
  132. This property tells TBAR how high each bitmap is.  This property is used, and
  133. may be used later to divide bitmaps horizontally as well as vertically.  The
  134. bitmap provided with the demo is 15 pixels high.
  135.  
  136. Bitmap
  137.  
  138. This is the property for the bitmap which represents the buttons on your toolbar.
  139. There are some important things for you to remember when designing your bitmap.
  140. All important areas of your bitmap should be outlined in black.  The black areas
  141. will be greyed when the bitmap is disabled.  The normal background color,
  142. RGB(128,128,128) (LTGRAY), must only be used for the background.  This color is
  143. masked out when re-drawing the button as pressed, toggled, and disabled.  You
  144. may not use another background color.  This is consistent with most toolbars
  145. currently in the industry.  The demo uses black and white as the only colors.
  146. Microsoft (TM) uses these colors in all of their applications.  You, however, may
  147. use other colors if it suits your purpose.  The only restrictions are those
  148. mentioned above.
  149.  
  150. VisibileButtons (Yea, I spelled it wrong, duh???)
  151.  
  152. This is the number of buttons visible on the screen.  It is possible to change the
  153. number of visible buttons at run-time to un-hide buttons at the end of the toolbar.
  154. I must warn you.  This feature is not tested.  I have plans in the works to allow
  155. drag and drop of buttons on the toolbar.  At that time, this feature will become
  156. more stable.  For right now, it might be best to only set this property at design
  157. time.  (But hey, try it if you want.)
  158.  
  159. LeadingInterval
  160.  
  161. This property is the number of pixels between the beginning of the toolbar and the
  162. first button on the toolbar.
  163.  
  164. CurrentButton
  165.  
  166. For setting button properties, this property determines which button will be affected.
  167. When you select a button with the right mouse button during design, this property will
  168. be set for you.
  169.  
  170.     TBar1.CurrentButton = 0
  171.     TBar1.Gap = "5"
  172.  
  173. ButtonState
  174.  
  175. This property is not available at design time.  You can change the enabled/disabled or
  176. toggled/untoggled state of a button by using this property.  The following values are
  177. hard coded by the system:
  178.  
  179.     BS_IS_TOGGLED                    1
  180.     BS_IS_ENABLED                    2
  181.     BS_IS_NOTTOGGLED                3
  182.     BS_IS_NOTENABLED                4
  183.     BS_IS_VISIBLE                    5
  184.     BS_IS_NOTVISIBLE                6
  185.  
  186. So, if I wanted to disable the second button (0 index) on the bitmap, I might do something
  187. like this:
  188.  
  189.     TBar1.ButtonState(2) = 4
  190.  
  191. Since the states of the button are indeterminite, reading this property will not return
  192. anything meaningful.  Additionally, in versions after 1.5, the index member of this
  193. property now corresponds to the ID of the bitmap, not the logical index of the bitmap.
  194. This allows the developer to change the button state of any button, no matter where it
  195. has been moved to by the user (if you are using AutoPlacement feature).  These new
  196. enhancements are fully compatible with previous versions.
  197.  
  198. RoundedCorners
  199.  
  200. Setting this propery to True will cause the edges of all buttos to appear somewhat rounded.
  201.  
  202. Id
  203.  
  204. This property sets and gets the id of the the button at the requested index.  This property
  205. allows you to set the bitmap of any button on the toolbar to any section of the bitmap your
  206. toolbar is using.  For example:
  207.  
  208.     You bitmap is 100 wide by 50 deep.  Each bitmap you are using for a button is 25 pixels
  209.     wide (ButtonWidth) and 25 pixels high (ButtonHeight).  So, the bitmap is divided into
  210.     4x2 bitmaps.  To set the first button in your toolbar to the first bitmap on the
  211.     second row, you can say:
  212.  
  213.         TBar1.Id(0) = 4
  214.  
  215.     Then, you can disable that same button by doing:
  216.  
  217.         TBar1.ButtonState(4) = 4    ' ButtonState uses Id for reference
  218.  
  219. You may use this property to get the Id(s) of each button in the toolbar as well.
  220.  
  221. AutoPlacement
  222.  
  223. Setting this property to True will allow the end user to drag and drop buttons on the
  224. toolbar to new places using the right mouse button.  Try this one out and see if it
  225. fits into your application.  You can save the placement using the IdList property and
  226. then restore the button order by setting this property when the application is
  227. started.  (See IdList.)
  228.  
  229. IdList
  230.  
  231. This property returns a string of Ids for each button in the bitmap.  You can then use
  232. this string later to restore the order of the buttons when the user restarts the
  233. program, or you can use it to set and show different sets of buttons in the toolbar.
  234. For example:
  235.  
  236.     ' Restore previous button state
  237.     Dim A$ As String * 81
  238.     GetPrivateProfileString("Toolbar","ButtonOrder","0;1;2;3;4;5;6;7;8;9",A$,80,"TOOLBAR.INI")
  239.     TBar1.IdList = A$
  240.  
  241. Now, say when the user pops up a certain document in an MDI application, you want to show
  242. four buttons which do a certain set of operations:
  243.  
  244.     Command1_Click()
  245.         TBar1.VisibileButtons = 4                ' Number of buttons on bar
  246.         TBar1.IdList = "12;13;14;15"            ' Each buttons Id
  247.     End Sub
  248.  
  249. BevelWidth
  250.  
  251. This property controls the width of the white and dark grey lines around the outside
  252. of the button.  Changing this property will enhance or reduce the 3D effects of the
  253. button.  Valid bevel widths are between 1 and 10.
  254.  
  255. PressedBevelWidth
  256.  
  257. This property controls the width of the black lines around the outside of the button
  258. when it is pressed.  Changing this property will enhance or reduce the 3D effects of the
  259. button.  Valid pressed bevel widths are between 1 and 10.  This value should always be
  260. less than or equal to the BevelWidth property.
  261.  
  262. Version
  263.  
  264. This property has been added to ensure backwards compatibility with all
  265. versions of TBar.
  266.  
  267. HelpForeColor
  268.  
  269. This property controls the color of the text in your popup help window.
  270.  
  271. HelpBackColor
  272.  
  273. This property controls the color of the background in your popup help window.
  274.  
  275. EnableHelp
  276.  
  277. This flag determines whether or not help is enabled for your toolbar.
  278. Setting this property to True will cause the help window to be displayed
  279. when the user leaves the mouse over one spot on a button for helpInterval
  280. number of milleseconds.  See HelpText under TOOLBAR BUTTON PROPERTIES for
  281. specifics on the help text.
  282.  
  283. HelpInterval
  284.  
  285. The delay in milleseconds before the help windows is displayed.  Timing
  286. starts when the user leaves the mouse cursor over a specific spot on the
  287. button.
  288.  
  289. HelpQuickInterval
  290.  
  291. This property is functionally equivelent to the HelpInterval property,
  292. except that this is the delay used after popup help has been shown for
  293. the first time, and the mouse has not left the toolbar.
  294.  
  295. HelpPosition
  296.  
  297. This property controls the location of the popup help window.  The default
  298. is for the window to show up 22 pixels beneath the mouse cursor, aligned
  299. left.  As an option, you may change this so that the popup help window will
  300. appear beneath the button.
  301.  
  302. HelpStyle
  303.  
  304. This feature is not implemented, but is reserved for future versions.  What
  305. I need is a little help creating a ballon type help window.  I don't know
  306. that much about trig.  A little help from my users would be appreciated.  The
  307. look I am looking for is a "cartoon" type balloon, with the help text in it.
  308.  
  309. Any help would be greatly appreciated.
  310.  
  311. ToolbarStyle
  312.  
  313. I added this property so that you can control the arranging of buttons on
  314. the toolbar.  The following is a brief description of each option:
  315.  
  316.     0 - Horizontal
  317.  
  318.     The buttons are placed one after another horizontally.  This is the
  319.     default.  The buttons will not wrap.
  320.  
  321.     1 - Horizontal w/Wrap
  322.  
  323.     The buttons are placed one after another horizontally.  This is the
  324.     default.  The buttons will wrap if they run over the end of the toolbar.
  325.     It is up to you to determine if the buttons are going to wrap, and resize
  326.     your toolbar vertically.  Note that any intervals will still apply, as will
  327.     any gaps.  This feature is mainly to be used to create a "toolbox" type
  328.     toolbar.
  329.  
  330.     2 - Vertical
  331.  
  332.     The buttons are placed on after another vertically.  The buttons will not
  333.     wrap.
  334.  
  335.     3 - Vertical w/Wrap
  336.  
  337.     The buttons are placed on after another vertically.  If the buttons would
  338.     run over the end of the toolbar, the will wrap vertically.  This is very
  339.     similar to number 1.  Either will work, I guess it just depends on what
  340.     order you want the buttons to appear in your toolbar.
  341.  
  342. There is another custon control, TBARWW, available on CompuServe, which will
  343. allow you to make a form always stay on top, like a real toolbox.  If you link
  344. that custom control with my toolbar, you will be able to create custom tool boxes.
  345.  
  346. TOOLBAR BUTTON PROPERTIES
  347.  
  348. Toolbar button properties are stored as strings.  So, you should always set these
  349. properties using strings.
  350.  
  351. Gap
  352.  
  353. This property represents the gap between CurrentButton and the next button.  This property
  354. is stored in Pixels.  The demo program uses this value to put spaces in between buttons
  355. in groups or which have similar purposes.
  356.  
  357.     TBar1.Gap = "10"        ' Put 10 pixesl between CurrentButton and the next
  358.  
  359. This property is mostly set at design time.  But you can set it at run time.
  360.  
  361. Sticky
  362.  
  363. This property determines whether or not the button can be "toggled".  Setting this
  364. property to "1" allows this button to remain pressed when the mouse is released, and
  365. then to be unpressed, when pressed with the mouse again.  Buttons with this property
  366. set to "1" will respond to the Toggle event.
  367.  
  368.     TBar1.CurrentButton = 1
  369.     TBar1.Sticky = "1"
  370.  
  371.     TBar1.CurrentButton = 1
  372.     TBar1.Sticky = "0"            ' Button is not sticky
  373.  
  374. Disabled
  375.  
  376. This property determines whether or not the button can be pressed with the mouse.
  377. Setting this property to "1" disables all "Click" events for that button.  Normal
  378. buttons on the toolbar provide a Click event when the mouse button is pressed then
  379. released on them.  In addition, the button will appear as "greyed" on the screen.
  380.  
  381.     TBar1.CurrentButton = 5
  382.     TBar1.Disabled = "1"
  383.  
  384.     TBar1.CurrentButton = 5
  385.     TBar1.CurrentButton = "0"    ' Renable button
  386.  
  387. Group
  388.  
  389. This property should only be used by "Sticky" buttons.  Sticky buttons can be grouped,
  390. so pressing one sticky button causes all other sticky buttons in the group to become
  391. unpressed.  You can enter the index of any other sticky buttons in the group
  392. separated by a comma.  This property should be set at design time, but you can read
  393. from and write to it at run time.  It is a string property as well.
  394.  
  395.     TBar1.CurrentButton = 8            ' Set the current button
  396.     TBar1.Group = "7,9"                ' Set the other buttons in his group
  397.  
  398. To disable the group set Group = "None"
  399.  
  400.     Tbar1.CurrentButton = 3
  401.     TBar1.Group = "None"
  402.  
  403.  
  404. ButtonVisible
  405.  
  406. This property defaults to True.  Setting it to False causes that button to be invisible.
  407. Note that the button that is affected is the controlled by the CurrentButton property.
  408. Note additionally, that the CurrentButton property is a logical index into the button
  409. array.  Along those lines, this property should really only be used at design time.
  410. Use the ButtonState property to hide and unhide buttons by ID during run time.
  411.  
  412. HelpText
  413.  
  414. This property controls what help text will be displayed when the help window
  415. is popped up.  You may not include the semi-colon character (;) in your
  416. help text.  If you want your help text divided up into more than one line,
  417. you can specify this by using the \r.  For example:
  418.  
  419.     TBar1.HelpText = "This text is divided into line one\rand line two"
  420.  
  421. Everything after the \r will appear on line two of the help window.
  422.  
  423.  
  424. TOOLBAR EVENTS
  425.  
  426. Click
  427.  
  428. This event is called when the user presses a "normal" button, and then releases the
  429. mouse over the button.  The parameter "Button", passed to this event, tells the
  430. developer which button was pressed.  Note that this parameter is now the button's id,
  431. in case AutoPlacement is turned on, clicking the same button, no matter where it has
  432. been moved, will cause the same Click command to be generated.
  433.  
  434.     TBar1_Click(Button As Integer)
  435.  
  436.         ' When save file is pressed, save the file, then disable the button until
  437.         ' the current document is dirty again.
  438.         Select Case    Button
  439.             Case 0:
  440.                 NewDocument
  441.             Case 1:
  442.                 OpenDocument
  443.             Case 2:
  444.                 SaveToFile
  445.                 TBar1.ButtonState(Button) = 4
  446.         End Select
  447.     End Sub
  448.  
  449. Toggle
  450.  
  451. This event is called when the state of a "Sticky" button changes.  If the sticky
  452. button is part of a group, then this event will be called twice, once for the button
  453. getting pressed, and once for the other button in the group which will be unpressed
  454. when the current button does down.
  455.  
  456.     TBar1_Toggle(Button As Intger, State As Integer)
  457.  
  458.         Select Case Button
  459.             Case 7:
  460.                 SetAligment LeftJustify,State
  461.             case 8:
  462.                 SetAlignment RightJustify,State
  463.             Case 9:
  464.                 SetAlignment CenterJustify,State
  465.         End Select
  466.  
  467.     End Sub
  468.  
  469. DoubleClick
  470.  
  471. This event is called when the user double clicks a button.  I'm not sure
  472. what this will be used for, but it is provided in case a user has
  473. special needs.
  474.  
  475. MouseDown
  476. MouseMove
  477. MouseUp
  478.  
  479. These events are called when a mouse action has taken place upon the
  480. toolbar.  Each one of these events take the following parameters:
  481.  
  482.     TBar1_MouseDown(MouseButton As Integer, Shift As Integer, X As Single,
  483.                         Y As Single, Button As Integer)
  484.     TBar1_MouseMove(MouseButton As Integer, Shift As Integer, X As Single,
  485.                         Y As Single, Button As Integer)
  486.     TBar1_MouseUp(MouseButton As Integer, Shift As Integer, X As Single,
  487.                         Y As Single, Button As Integer)
  488.  
  489. MouseButton indicates which mouse button caused the event.  This parameter
  490. is equivelent to the Button parameter for normal MouseDown events, as in
  491. the VB Help File.  This parameter is 1 for the left button, 2 for the right
  492. button, and 4 for the middle button.
  493.  
  494. Shift represents the state of the Ctrl and Shift keys.  I did not include
  495. the Alt key.  I didn't see the purpose for this, and the Alt key state is
  496. not provided as a default in the mouse event.  I will include the Alt key
  497. state if any requests me to do so.  The shift states are 1 for Shift down,
  498. and 2 for Control button down.
  499.  
  500. X is the location on the screen, in twips of the mouse events x location.
  501.  
  502. Y is the location on the screen, in twips of the mouse events y location.
  503.  
  504. Button is the toolbar button, over which, the current mouse event took
  505. place.  If there was no button under the mouse event, then this parameter
  506. will be equal to negative 1.
  507.  
  508. ***************************************************************************
  509.  
  510. REACHING THE AUTHOR
  511.  
  512. I can be reached via U.S. Mail at the address listed above.  You can reach
  513. me via E-Mail at the following locations...
  514.  
  515. CompuServe:            Robin W. McKean
  516.                     72622,1403
  517.  
  518. Shareware South:    (404) 370-0872
  519.                     Robin W. McKean
  520.                     Atlanta, GA
  521.  
  522. I'm on CompuServe once or twice a day.  I check Shareware South about once
  523. a week.
  524.  
  525. ***************************************************************************
  526.  
  527. REVISION HISTORY
  528.  
  529. 1.00.0000    Initial release of the TBAR.VBX Custom Control
  530. 1.50.0000    Added properties for visible buttons, ids, bevels,
  531.             autoplacement, rounded corners, and improved the
  532.             look of disabled bitmaps.
  533. 1.51.0000    Fixed bug when loading a form saved as text
  534. 1.52.0000    Fixed button staying depressed when modal form is
  535.             called up by button click event.
  536. 2.00.0000    Implemented popup help
  537. 2.10.0000    Various bug fixes.  Added VERSION info.
  538. 2.11.0000    Remove balloon/popup help when top window no longer active
  539. 2.40.0000 Added on line help and fixed a few bugs
  540.  
  541. ***************************************************************************
  542.  
  543. ACKNOWLEDGEMENTS
  544.  
  545. Thanks to James Moore for the bug report on Forms saved as text.
  546.  
  547. Thanks to Terje Enge for his instrumental help in beta testing TBar 2.0.
  548.  
  549. Thanks to Kevin Klasman for the online help.
  550.  
  551. Thanks to the group in Europe which helped me with the vertical placement
  552. issues.  Sorry I lost your mail to give you credit.
  553.  
  554. ***************************************************************************
  555.