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 Re-Visited

A big problem for AutoCAD uses when creating or custumising toolbars is ensuring that all the bitmap files used by the toolbar are available and within the AutoCAD search path. In my tutorial "Creating a Toolbar DLL" I explained how to create a DLL file to store all your toolbar bitmaps using the Visual Basic Resource Editor. Now this is great if you're lucky enough to have VB6, but what if you haven't? Well, I was introduced to a great little FREE application the other day that will allow you to create and edit DLL files without having VB6 installed. This application, called "Resource Hacker," was written by Angus Johnson and you can find it at :

Resource Hacker
http://www.users.on.net/johnson/resourcehacker/

AutoCAD Usage :

Before you start, please unload the relevant menu file from AutoCAD and then delete the MNC, MNS and MNR files belonging to the menu. You should be left with just your MNU file. This is to prevent AutoCAD from getting confused.

First you must install "Resource Hacker."
Secondly have all your toolbar bitmap files ready and in one directory.
As far as I know, you cannot create a new DLL file using the "Resource Hacker," so I have supplied an empty DLL file called "AfraLisp.dll." I would suggest you place this file in the same directory as your bitmap files.

I have supplied some sample bitmaps and a sample AutoCAD Toolbar menu to use as an example.

O.K. away we go. Fire up the "Resource Hacker."
From the pulldown menu select "File" -> "Open" and select "AfraLisp.dll."
Next, select "Action" -> "Add a new Resource."

The "Add a New Resource" dialogue will appear:

Click the "Open file with new resource" button, and select your first bitmap file.

In the "Resource Name" text box, enter the name of your bitmap, excluding the file extension:


Next, click on the "Add Resource" button:

Under the resource list your bitmap file will appear.

Repeat this process for all additional bitmap files.
When you have finished, the resource list should look like this:

 

Now, choose "File" -> "Save As" and save the file as "vbatoolbar.dll."

Now this is extremely important. The DLL file must have EXACTLY the same name as your menu name and MUST be in the same directory. Copy the DLL file to the same directory as your MNU file.

O.K. we've now created out Menu DLL file, but we still have to make some changes to our menu file.

Open the menu file "vbatoolbar.mnu." 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.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]

You now need to remove the file extension from all of the bitmap references. Your menu file should now 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]

You are now ready to try out your menu. Load and run it. Your toolbar should appear and look like this :

That's it, no more "smiley faces." Simple hey?

You can now remove all your bitmap files. Do yourself a favour though, keep them somewhere safe so that if you have to re-compile your DLL files, you still have your source bitmaps.

To download the source files for this tutorial including the empty DLL file,

just click here - Download VbaDll.Zip (8kB)

 
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