AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Creating a Toolbar DLL (14Kb)

Are you sick and tired of having all those Toolbar Bitmap Files floating around?
And, what a pain it is having to remember to attach the bitmaps along with the
Toolbar menu file every time you send it to someone, or install the menu on another workstation. (Smiley Faces here we come..)
The solution to this, is to store the Bitmaps in an ActiveX DLL file. (The same as
AutoCAD do with their Toolbar Bitmaps.) Here's the steps to construct your own,
customized Toolbar DLL.
Unfortunately, you will require the Visual Basic Resource Editor which is only
included with VB6. (I do believe though, that the Resource Editor is available as a plug-in for VB5.)


Firstly, you need to build your Toolbar along with all relevant Bitmaps and test it within AutoCAD. Here is the menu file for the VBA Toolbar which is in the downloadable sample file : 
***MENUGROUP=VBA

***TOOLBARS

ID_VBA_0  [_Toolbar("VBA", _Floating, _Show, 350, 246, 1)]
ID_VBA_1  [_Button("VBA Load", "vbaload.bmp", "vbaload32.bmp")]^C^C_vbaload 
ID_VBA_2  [_Button("VBA Macro", "vbamacro.bmp", "vbamacro32.bmp")]^C^C_vbarun 
ID_VBA_3  [_Button("VBA Editor", "vbaide.bmp", "vbaide32.bmp")]^C^C_vbaide 
ID_VBA_4  [_Button("VBA Manager", "vbaman.bmp", "vbaman32.bmp")]^C^Cvbaman 

***HELPSTRINGS

ID_VBA_1  [Load VBA Project]
ID_VBA_2  [Run VBA Macro]
ID_VBA_3  [Load VBA Editor]
ID_VBA_4  [Load VBA Manager]

Your Toolbar should look like this :

VBA Toolbar

Now, do yourself a favour and store the Menu file and all Bitmaps into their own sub-directory. If you don't, you will find it a problem later on when editing the DLL file to locate all the VB support files.

Now fire up VB6 and start a new ActiveX DLL project. Next, open the VB6 Resource Editor. If it is not loaded, go to the Add-In Manager and load it.

VBA Toolbar

Once in the Resource Editor, load each of your Bitmap Files, renaming each Bitmap to match that of the relevant name in the menu. (Right-Click on each name and select Properties.) Now save your project. (Save it using the same name as your Menu and to the same sub-directory.)
Finally, choose "File" - "Make YourMenuName.DLL", again saving it to the same directory. (It is important that the DLL file has the same name as the Menu.)
You can now exit VB6. (saving any files if prompted.)

One final step. (Well, a couple!!) Open up your Menu file and remove the .BMP extension from the Bitmap file names. It should look like this : 

***MENUGROUP=VBA

***TOOLBARS

ID_VBA_0 [_Toolbar("VBA", _Floating, _Show, 350, 246, 1)]
ID_VBA_1 [_Button("VBA Load", "vbaload", "vbaload32")]^C^C_vbaload 
ID_VBA_2 [_Button("VBA Macro", "vbamacro", "vbamacro32")]^C^C_vbarun 
ID_VBA_3 [_Button("VBA Editor", "vbaide", "vbaide32")]^C^C_vbaide 
ID_VBA_4 [_Button("VBA Manager", "vbaman", "vbaman32")]^C^Cvbaman 

***HELPSTRINGS

ID_VBA_1 [Load VBA Project]
ID_VBA_2 [Run VBA Macro]
ID_VBA_3 [Load VBA Editor]
ID_VBA_4 [Load VBA Manager]

Then copy your Menu file and the DLL file to any of your AutoCAD support path
directories. You now need to re-compile your Menu file. To do this, first delete all MNS, MNC and MNR files with the same name as your menu. Then fire up AutoCAD and load your menu. Hopefully, no smiley faces......

From now on, all you need to do to distribute your menu is to include the DLL file
along with the Menu file. Bye, Bye Bitmaps.....

 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website