Author Topic: Pulldown menu icons  (Read 5410 times)

0 Members and 1 Guest are viewing this topic.

tdaniel14

  • Guest
Pulldown menu icons
« on: July 21, 2006, 02:13:47 PM »
AutoCAD 2006 has icons on the pulldown menus.  Does anyone know if it is possible to add the icons through VBA code.  I have code that adds menu items but I can't add the image.  By the way, all my custom bitmaps are in a dll file.

DaveW

  • Guest
Re: Pulldown menu icons
« Reply #1 on: July 23, 2006, 12:02:16 PM »
Hi,


Take a look at the attached zip file. In it you will find a dll for the bitmaps and a mns file.

For 2006 and 2007, you should let 2006 or 2007 create the cui file for you. Do them seperatly, as I have noticed that cui files created in 2006 and then loaded in 2007 can have issues, but if you convert it in 2007 the cui works fine.

Remember, you must have the dll and the cui or mns in the same folder, they should be the same name except for the extention and should be in the support path.

If there is anything else you need, please let me know.

Good Luck,

Dave

tdaniel14

  • Guest
Re: Pulldown menu icons
« Reply #2 on: July 25, 2006, 08:14:41 AM »
Thanks for the reply.  What I've done is added a menu item with vba to my custom menu.  Now what I want to do is (with vba code) add an image to the added menu item.  Is this possible through vba code?

DaveW

  • Guest
Re: Pulldown menu icons
« Reply #3 on: July 25, 2006, 08:52:20 AM »
That is a good question. I add custom menus to the right click menus with vba, so I bet it is possible. I have never seen it done however. Sorry I can't be more help.

Dave R

  • Guest
Re: Pulldown menu icons
« Reply #4 on: July 25, 2006, 12:33:00 PM »
It's not possible in VBA code unless you delve into the Windows API. AutoCAD does not expose those properties in the VBA API. It is only possible to add icons to dynamically created toolbars.

DaveW

  • Guest
Re: Pulldown menu icons
« Reply #5 on: July 25, 2006, 06:45:20 PM »
Take a look at this code. It appears this is how its done and that Dvae R is incorrect. Who knows, maybe it does not work, but it should, the method is there. I have not tested it.

Code: [Select]
Sub Ch6_AddButton()
    Dim currMenuGroup As AcadMenuGroup
    Set currMenuGroup = ThisDrawing.Application.MenuGroups.Item(0)
   
    ' Create the new toolbar
    Dim newToolbar As AcadToolbar
    Set newToolbar = currMenuGroup.Toolbars.Add("TestToolbar")
   
    ' Add a button to the new toolbar
    Dim newButton As AcadToolbarItem
    Dim openMacro As String
   
    ' Assign the macro the VB equivalent of "ESC ESC _open "
    openMacro = Chr(vbKeyEscape) + Chr(vbKeyEscape) + "_open "
    Set newButton = newToolbar.AddToolbarButton("", "NewButton", "Open a file.", openMacro)
    newButton.GetBitmaps "1.BMP", "2.BMP"
   
End Sub


Bob Wahr

  • Guest
Re: Pulldown menu icons
« Reply #6 on: July 25, 2006, 06:51:53 PM »
DaveW, That works swell for toolbar buttons but tdaniel14 isn't looking for toolbar buttons, tdaniel14 is looking for icons on pulldown menu (aka PopupMenu) which from very limited testing, help looking, and intellisense checking, it appears that DaveR is right unless there is a hidden method.

DaveW

  • Guest
Re: Pulldown menu icons
« Reply #7 on: July 25, 2006, 07:50:03 PM »
DaveW, That works swell for toolbar buttons but tdaniel14 isn't looking for toolbar buttons, tdaniel14 is looking for icons on pulldown menu (aka PopupMenu) which from very limited testing, help looking, and intellisense checking, it appears that DaveR is right unless there is a hidden method.


You are both right. I jumped the gun. I burned my arm and was not paying careful attention. My apologies Dave.

The AcadToolbar does have the SetBitmaps method, but the AcadPopupMenu does not.

I have a feeling that what we are trying to do may be possible if the naming is the same, but have not been able to get ACAD to do it.
« Last Edit: September 12, 2006, 11:50:01 PM by DaveW »

Bob Wahr

  • Guest
Re: Pulldown menu icons
« Reply #8 on: July 25, 2006, 08:01:29 PM »
If you look at the CUI instead of the MNC
Code: [Select]
      <MenuMacro UID="MMU_0216">
        <Macro type="Any">
          <Revision MajorVersion="16" MinorVersion="2" UserVersion="1" />
          <Name xlate="true" UID="XLS_0245">Ledger</Name>
          <Command>^C^C^P(IF(NOT C:LEDGER)(load "SNA-LEDGER.lsp"));LEDGER; </Command>
          <SmallImage Name="SNA-LEDGER.bmp" />
          <LargeImage Name="SNA-LEDGER.bmp" />
        </Macro>
      </MenuMacro>
but I would NOT in any way, for any reason, for any amount of money, modify the CUI directly via VBA or for that matter anything else.  OK, I lie, I would do it for money and it wouldn't even take much.

DaveW

  • Guest
Re: Pulldown menu icons
« Reply #9 on: July 25, 2006, 08:06:06 PM »
That would work and be difficult with unforseen problems, but....it is a cool work a round!!

tdaniel14

  • Guest
Re: Pulldown menu icons
« Reply #10 on: July 25, 2006, 11:11:04 PM »
Hey, Thanks for the help!  Found a solution and another problem!  I have two macros, one that deletes a menu item and one that adds the menu item back.  The original menu item was created through the CUI and displays the icon.  I run the macro to delete the item then go into the CUI and the menu item is still there(does not show up on my pulldown menu).  If I add the menu item back, the icon does not display.  (WHEN I MODIFY THE CUI AND CLICK OK, THE CUI RECOMPILES AND THE ICON IS DISPLAYED ON THE PULLDOWN :-D).  The problem is that you can't save the menugroups through vba anymore.  Do you guys know of a way to make the CUI recompile/refresh?

DaveW

  • Guest
Re: Pulldown menu icons
« Reply #11 on: July 26, 2006, 12:25:35 AM »
Not I. However, you may want to take a look at 2007 too, as they did fix some stuff in the cuis in that build I am told.

Are you planning on changing the menus and their context automatically? The reason I ask is, if not then what is the reason for doing what you are doing anyway?

Let me give you an example:

I have several different menus. Popup, Toolbars and the different right-click menus. I make my popups and toolbars static and stand alone. This keeps ACAD from recompiling mine when it exits and also allows me to have it completely separate from ACAD so I do not have to change the ACAD mns or cui.

The right click menu is different. Either I edit the main ACAD menu file or insert onto it what I want and where I want it with VB. I choose the latter as I do not want to modify the users stock acad file.

« Last Edit: July 26, 2006, 12:34:34 AM by DaveW »

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1368
  • class keyThumper<T>:ILazy<T>
Re: Pulldown menu icons
« Reply #12 on: March 26, 2009, 11:02:37 PM »

I'd like to follow up on this.

Has anyone had any joy adding bitmaps to Pulldown Menu's
with either a MNU file or programmatically.

.... either from Lisp or .NET

Regards
Kerry
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

Spike Wilbury

  • Guest
Re: Pulldown menu icons
« Reply #13 on: March 26, 2009, 11:22:03 PM »

I'd like to follow up on this.

Has anyone had any joy adding bitmaps to Pulldown Menu's
with either a MNU file or programmatically.

.... either from Lisp or .NET

Regards
Kerry


Kerry;

There is an ADN comment about this....

Quote
"Currently, the AutoCAD ActiveX interface do not have a straightforward method to create a menu with an ICON besides its menu text. We logged a wishlist some time ago, but it was deferred because, mostly because the new Ribbon interface."

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1368
  • class keyThumper<T>:ILazy<T>
Re: Pulldown menu icons
« Reply #14 on: March 27, 2009, 01:21:11 AM »


Thanks Luis

They've obviously forgotten that a lot of us use Menuload of partial menus from MNU files

Quote
... do not have a straightforward method ...


I wonder if they have ANY method ??
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

Dave R

  • Guest
Re: Pulldown menu icons
« Reply #15 on: March 27, 2009, 08:17:25 AM »
Kerry, what are you doing in the VBA forum? Shame on you.  :lmao:

Spike Wilbury

  • Guest
Re: Pulldown menu icons
« Reply #16 on: March 27, 2009, 11:21:50 AM »


Thanks Luis

They've obviously forgotten that a lot of us use Menuload of partial menus from MNU files

Quote
... do not have a straightforward method ...


I wonder if they have ANY method ??


Kerry,

What I have done is to once my MNU it is loaded (I have done it in ARX the making of my MNU, too) - it will generate a CUI and do a modification depending where I want to have an icon, I just look for:

Quote
        <Macro type="Any">
          <Revision MajorVersion="16" MinorVersion="2" UserVersion="1" />
          <ModifiedRev MajorVersion="17" MinorVersion="0" UserVersion="1" />
          <Name xlate="true" UID="XLS_0002">Unload Menu</Name>
          <Command>^C^CUNLOADSUPP </Command>
          <SmallImage Name="unloader.bmp" />
          <LargeImage Name="unloader.bmp" />
        </Macro>

Then, I loaded again.... I know but so far that's what it works for me

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Pulldown menu icons
« Reply #17 on: March 27, 2009, 09:44:47 PM »

Thanks for the thought Luis.
I found the source of your ADN reference in the discussion groups ... wasn't much help was it ;)

I may need to write my own updater for the .CUI, .CUIx files ... UGH !
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Pulldown menu icons
« Reply #18 on: March 27, 2009, 09:46:17 PM »
Kerry, what are you doing in the VBA forum? Shame on you.  :lmao:

H Dave,
One does what one must.  :-P    :-)
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--