Real Software Forums
http://forums.realsoftware.com/

Toolbar Extenders
http://forums.realsoftware.com/viewtopic.php?f=21&t=44688
Page 1 of 1

Author:  shaosean [ Thu Jul 12, 2012 6:04 am ]
Post subject:  Toolbar Extenders

I got a little tired of the convoluted mess my code was becoming when working with toolbar items, so I made this handy little module that should hopefully make working with them easier.. Everything is in a set/get pair of methods..

Here is an example of setting the caption using the built-in methods
ToolButton(MyToolbar.item(0)).Caption = "hello world"


and an example with the extender
MyToolbar.ItemCaption("itemName") = "hello world"

where "itemName" is the name of the toolbar item

Find it on my site http://shaosean.tk/
It is completely free and in the public domain.. I wash my hands of it ;-)

Author:  Markus Winter [ Thu Jul 12, 2012 7:05 am ]
Post subject:  Re: Toolbar Extenders

Nice, but why do you cast in your example?

MyToolbar.Item( 0 ).Caption = "hello world"

would do.

Author:  timhare [ Thu Jul 12, 2012 12:12 pm ]
Post subject:  Re: Toolbar Extenders

Did you try that code? Toolbar.Item returns a ToolItem, not a ToolButton. ToolItem does not have a Caption property. Casting is necessary for most of the properties you care about.

Author:  Markus Winter [ Thu Jul 12, 2012 1:26 pm ]
Post subject:  Re: Toolbar Extenders

Yes, I did. Autocompletes with caption.

Author:  shaosean [ Thu Jul 12, 2012 1:53 pm ]
Post subject:  Re: Toolbar Extenders

Indeed it does autocomplete with .caption and it indeed does update the caption of the toolbar item.. According to the docs, it shouldn't work.. Is this a bug or an undocumented feature? ;-)

But regardless, I still think it is easier to work with the toolbar items based on their name instead of their positioning in the toolbar as this allows you to move them around without breaking your code..

Author:  timhare [ Thu Jul 12, 2012 1:56 pm ]
Post subject:  Re: Toolbar Extenders

Then things have changed since I last fiddled with toolbars. I'm pleasantly surprised.

Author:  shaosean [ Thu Jul 12, 2012 2:26 pm ]
Post subject:  Re: Toolbar Extenders

My bad.. I forgot an "Assigns" in the ItemEnabled setter, so just replace that method with this one (or add "Assigns" to the pEnabled parameter)

Sub ItemEnabled(Extends pToolbar As Toolbar, pItemName As String, Assigns pEnabled As Boolean)
for i As Integer = 0 to (pToolbar.Count()- 1)
if (ToolButton(pToolbar.Item(i)).Name = pItemName) then
ToolButton(pToolbar.Item(i)).Enabled = pEnabled
exit for i
end if
next
End Sub

Author:  Paul Lefebvre [ Thu Jul 26, 2012 11:19 am ]
Post subject:  Re: Toolbar Extenders

shaosean wrote:
Indeed it does autocomplete with .caption and it indeed does update the caption of the toolbar item.. According to the docs, it shouldn't work.. Is this a bug or an undocumented feature? ;-)

Seems like a documentation bug to me. I've updated the Language Reference so that Caption (and Tag) are now properties of ToolItem.

Author:  swort [ Sun Jul 29, 2012 7:18 am ]
Post subject:  Re: Toolbar Extenders

If you have more extentions to classes, please let me know.
I can put them inside the DutchTools module and maintain a wiki for it.

It's located on GitHub. You can share them with me or place them as suggestion on the Tips forum here.
I'll be watching this forum about every day (as usual).

You can download my classes FREE under the MIT license here:
https://github.com/sworteu

Author:  shaosean [ Sun Jul 29, 2012 4:15 pm ]
Post subject:  Re: Toolbar Extenders

Thanks for the link swort.. I noticed that you posted about using the MIT license (no idea what that is), but I just thought I would let everyone know that I release my code in to the public domain - no licenses, no restrictions, no forced sharing of source code, etc..

Author:  swort [ Mon Jul 30, 2012 11:59 am ]
Post subject:  Re: Toolbar Extenders

shaosean wrote:
Thanks for the link swort.. I noticed that you posted about using the MIT license (no idea what that is), but I just thought I would let everyone know that I release my code in to the public domain - no licenses, no restrictions, no forced sharing of source code, etc..


Well a MIT license is a license for free usage.
http://opensource.org/comment/935

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/