home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / t_bar / read.txt < prev    next >
Text File  |  1994-05-29  |  21KB  |  556 lines

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