VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BUTTON IMAGE ICON RESOURCE DLL FILE NOT WORKING

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
bobmc
3541 Views, 13 Replies

BUTTON IMAGE ICON RESOURCE DLL FILE NOT WORKING

Spent the last week converting all our company’s toolbars into a ribbon.  This included fixing the transparency on 111 button image files, then making 16x16 and 32x32 pixel and dark theme and light theme versions of each, for a total of 444 image files.  All the button image files are BMP’s created in Photoshop Elements in 24-bit color.  They all display properly if either the dark or light theme version files are placed in the same directory as our enterprise cuix file.

 

However, I cannot get the button images to display after assembling them into dark theme and light theme resource DLL files.  From everything I have found online, I am creating the resource DLL’s properly and do not understand why they are not working.  Below are the particulars of how I am creating the resource DLL files:

 

Windows 7 64-bit operating system

AutoCAD 2015 ver. J.51.0.0 (64-bit)

 

Visual Studio Express 2012 for Windows Desktop ver. 11.0.60315.01 update 2:

 

New Project

   Visual C++

      Win32 Project, Name:  <our cuix menu name>

         Win32 Application Wizard

            Application type:  DLL

               Security Development Lifecycle (SDL) checks selected by default

                  Finish

 

Solution Explorer

   <our cuix menu name> properties

      Configuration Manager

         Active solution configuration:  Release

         Active solution Platform: <New>

            Type or select new platform:  x64

            Copy settings from:  Win32

            Create new project platforms selected by default

         Project contexts…

            Project:  <our cuix menu name>

            Configuration:  Release

            Platform:  x64

            Build:  selected by default

         Close

      Linker

         Advanced

            No Entry Point:  Yes (/NOENTRY)

   OK

 

Solution Explorer

   Resource Files

      Right-click Add, Existing Item…

         Browse to folder containing dark theme button images

            Select all button image files

               Add

 

Build

   Build Solution

      <our cuix menu name>.vcxproj -> … <our cuix menu name>.dll

         Build:  1 succeeded (no errors)

 

Copy <our cuix menu name>.dll to folder which contains <our cuix menu name>

   Delete <our cuix menu name>.mnr and <our cuix menu name>_light.mnr files

 

Launch AutoCAD 2015

   Curse at all button images being clouds with question marks!

 

The size of each resource DLL is 4.50Kb, but the size of each theme of button images is 428KB.  So obviously the images are not getting embedded in the DLL files.  Not sure what I am missing here, but I need to get this working.  Any help would be greatly appreciated!

13 REPLIES 13
Message 2 of 14
owenwengerd
in reply to: bobmc

You need to add the bitmap files to your resource script. Use the Resource View palette, right click on the .rc file, then Add resource and [Import].

--
Owen Wengerd
ManuSoft
Message 3 of 14
bobmc
in reply to: owenwengerd

Thanks for your reply!  I am using the Express edition of Visual Basic, so I do not have a Resource View palette, and I discovered I cannot create or edit an .rc file from within VSE.  However, based on your reply and a little more web research, I think I realize what I am doing wrong.  In the VSE Solution Explorer, under Resource Files, I was adding all the bitmap files individually.  I believe what I need to do is create the resource file in Notepad, and just add the single .rc resource file to the project.  At MSDN (Bitmap resource file) I found that the bitmap resource file should simply refer to each bitmap in the following way, one line per button image:

 

<button image name>   BITMAP   "<path & image name.bmp>"

 

I will make these .rc files manually, add them to the project, and see if this works.  I will post my results once I am done.  Thanks again.

Message 4 of 14
bobmc
in reply to: bobmc

Still missing something here.  Attached is the dark-theme Landscape.rc resource file I created in Notepad.  (I had to add the .txt extension to allow it to be attached.)  I place the compiled x64 Landscape.dll file in the same folder as our Landscape.cuix file.  Delete the Landscape.mnr file.  Changed the button image names in the cuix editor from <button image name>.bmp to just <button image name> to be identical to the nameID's in the resource file.  Still all clouds with question marks for button images.  Do not know what else to try.  Any help would be greatly appreciated!

Message 5 of 14
owenwengerd
in reply to: bobmc

Open your .dll in VS' resource editor and verify that the bitmap resources are named and not numbered. If they're numbered, it won't work. If they're named, verify that the names match exactly. Test with a simple .mnu that contains only a single toolbar button. If the simple .mnu fails, attach it here along with your .dll so I can have a look.

--
Owen Wengerd
ManuSoft
Message 6 of 14
bobmc
in reply to: owenwengerd

Thanks for your help Owen!  Should the RC file have a #INCLUDE <header> statement, and what headers would be included?  Or is the one I created from scratch OK as I attached yesterday?  Visual Basic Express does not allow me to edit DLL files, so I downloaded Open Freely from the Microsoft link and looked in the DLL with its resource editor.  All my button image BMP's are in there with the correct names, no numbers.  So I made a new CUIX file with one simple toolbar from our larger selection.  The toolbar has 5 button images named the same as the ones in the DLL file (no .bmp extensions).  Still just clouds and question marks.  So I've attached the DLL and CUIX files.   I hope the CUIX file is OK, as I have not used MNU files for many years.  I created most of our company's custom toolbars originally as MNU files, but I would have to dig hard now to find one to start with!

Message 7 of 14
owenwengerd
in reply to: bobmc

Your .rc file looks fine. There is no need to include anything.

 

I looked at your .dll file, and the resources inside look correct. However, the filename does not match the .cuix filename. Could that be the problem? I'll wait to test further until you reply. I prefer a .mnu for testing because it's easier to see inside and edit on the fly, but I can work with your .cuix.

--
Owen Wengerd
ManuSoft
Message 8 of 14
owenwengerd
in reply to: owenwengerd

I decided to go ahead and test anyway. I renamed Landscape.dll to DLL_test.dll, loaded the DLL_test.cuix, and got a toolbar with buttons displayed correctly. Hopefully it's just a simple filename issue.

--
Owen Wengerd
ManuSoft
Message 9 of 14
bobmc
in reply to: owenwengerd

SUCCESS!!  But no, it was not a simple file naming issue.  The file was named DLL_test.dll when I was trying it, but I grabed the Landscape.dll file when I had to make a ZIP to get the attachments to upload.  Same file, different names.  However, since it worked on your end it set me to thinking why it was not working on my end.  And I remembered the bitmaps were not being incorporated in the DLL file when I was originally using their mapped network drive designation F:\<path><filename>, nor did they get incorporated when I used <\\server02\data\<path><filename>>.  I finally put them on my C: drive and got the DLL's built.  So even though F:\<path><cuix folder> is in the Support File Search Path for AutoCAD, I added <\\server02\data\<path><cuix folder>> also.  Deleted the MNR files, and voila!  Light and dark theme icons are switching correctly in our company's ribbon panels!  Definitely a lot more challenging to create ribbons than toolbars, and the light and dark themes add a lot more complexity the first time around.

 

Curiously, none of our company's existing toolbars or the DLL_test.cuix toolbar button images change when you switch themes, only the ribbon button images.  This is the last hurdle for our company CUIX file.  Does the test toolbar I sent you change correctly?  Here, if you delete the MNR files, it loads the correct icons for the current theme at startup, but they never switch per the theme like the ribbon button icons.  But I see that the standard ACAD toolbar button images change with the theme.  Any ideas on this one?  Or just more ammo to get users to switch to the ribbon, which is the ultimate goal anyhow!   THANKS FOR ALL YOUR HELP!!  I was at a dead end, and now have a great new ribbon for our office to use, no matter which theme the user prefers.

Message 10 of 14
owenwengerd
in reply to: bobmc

You're welcome, I'm glad you got it straightened out. There's a long thread in the AutoCAD 2015 group about the dark vs. light problem. In short, it's a bug with a fix in the pipeline. The workaround is to stash the correct .mnr file for one version, rebuild for the other, then replace the now incorrect version with the stashed one and timestamp it so it won't get recreated.

--
Owen Wengerd
ManuSoft
Message 11 of 14
bobmc
in reply to: owenwengerd

Your last post fixed the toolbar theme switching also.  I marked the topic as solved and gave you kudos for all your help.  You are an awesome community contributor!  THANKS AGAIN!! 

Message 12 of 14
smbrennan
in reply to: owenwengerd

Guys - 

 

I am trying to achieve this switching, but I don't know programming (but have an in-house employee who knows Visual Basic, but not familiar with AutoCADs API).

 

Is there a way without programmingto achieve managing icons for dark vs light schemes (without having 2 CUIX files)? Or, are either one of you willing to provide me with a base Visual Studio File and some basic instructions that I can manipulate and get the results I need?

 

Any help would be appreciated.

Shawn B.

  ||    
To help improve Autodesk Products, please Click Here to Vote for ideas and submit your own.
Message 13 of 14
bobmc
in reply to: smbrennan

If your employee knows Visual Basic, he should be able to compile the resource files to accomplish light and dark theme button image swapping without knowing AutoCAD.  Have him start here:  Through the Interface  This AutoDesk blog outlines what is necessary to accomplish the theme switching, and is where I started.  Here's another AutoCAD discussion thread I found useful:  Icon Menu Resource DLL  If you get stuck, I'm sure I or others can assist through the discussion groups.  Good luck!

Message 14 of 14
hawstom
in reply to: owenwengerd

2020 update: This entire thread, especially Bob's play-by-play of Visual Studio and Owen's explanation about adding images to a resource file, was very instrumental in helping me finally figure this out after a week of effort. I created some sample files and a blog post to explain the entire process in detail. http://tomsthird.blogspot.com/2020/03/creating-custom-menu-button-icon-image.html

 

It turns out to be pretty simple once you finally figure it out, just like most things.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost