cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Developer forum

Add menu icon

Martin Walter
Enthusiast
I would like to add an icon to my menu entries:
How can I do this?
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD
1 ACCEPTED SOLUTION

Solution
Martin Walter
Enthusiast
I finally solved the problem for me.
The indexes are the problem. It is not working this way:
'STR#' ID_MENU_STRINGS_NEW "Menu strings" {
/* [    ] */		"Planersoftware 2.0"
/* [  1] */		"Erstelle neues Fenster oder Tür^32101"
}
But this way:
'STR#' ID_MENU_STRINGS_NEW "Menu strings" {
/* [  1] */		"Planersoftware 2.0"
/* [  2] */		"Erstelle neues Fenster oder Tür^32101"
}
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

View solution in original post

17 REPLIES 17

Ralph Wessel
Mentor
Add the icon resource ID in the menu item resource like this:
"Help^32529"
Ralph Wessel BArch

Martin Walter
Enthusiast
I can't get it working.
No icon pictures show in my menu.

But the image is compiled correctly because in the RO directory appears a buttonVekaCreate&96.ico file.

This is my code:
------------------------------------
in RegisterInterface (void):

err = ACAPI_Register_Menu(ID_MENU_STRINGS1, ID_STATUS_STRINGS1, MenuCode_UserDef, MenuFlag_Default);
------------------------------------
in file .grc:

'STR#' ID_MENU_STRINGS1 "Menu strings" {
/* [  1] */		"WinDoPlan"
/* [  2] */		"Neues Fenster oder Tür^33000"
}
--------------------------------------
in file ...fix.grc:

'GICN' 33000 "buttonVekaCreate icon" {
    "buttonVekaCreate"
}
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

Ralph Wessel
Mentor
How about the format and naming of your source images?
Ralph Wessel BArch

Martin Walter
Enthusiast
I'm working on windows and saved the images into the folder ..\RFIX\Images\
as .png
e.g. buttonVekaCreate.png

and my command for compiling the resources is taken from the examples:
..\APIDevelopmentKit23\Tools\Win\ResConv.exe" -m r -D WINDOWS -T W -q utf8 1252 -i "RINT\$(ProjectName).grc" -D _DEBUG -o "$(OutDir)\RO\$(ProjectName).grc.rc2
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

Ralph Wessel
Mentor
Are you able to confirm that the resources and images are correctly embedded in the built add-on?
Ralph Wessel BArch

Martin Walter
Enthusiast
the file ArchicadPluginFix.grc.rc2 in the RO folder looks like this:


//nclude "DGDefs.h"

/*---- This file was created by GRC compiler --------------------------------------------*/
/*                                                                                       */
/*     Source file: RFIX\ArchicadPluginFix.grc              Code table: NUL              */
/*                                                                                       */
/*---- Version 2.0 - Windows ------------------------------ (c) 1996-2019 by GRAPHISOFT -*/


#include "MDIDs_APICD.h"

32500 MDID
BEGIN
	8, 0,
	0L + 707017037,
	0L + 4022811608
END

I33000&96	ICON "buttonVekaCreate&96.ico"

I33001&96	ICON "buttonVekaChange&96.ico"

I33002&96	ICON "buttonVekaSettings&96.ico"
-------------------------------------

so the icons are created
and I find the files in the RO folder:
buttonVekaChange&96.ico
buttonVekaCreate&96.ico
buttonVekaSettings&96.ico


what else can I check?
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

Martin Walter
Enthusiast
Obviously this is a BUG in Archicad API.
For the second level menu items the icons are working.
But not for the first level:

'STR#' DGTEST_MENU_STRINGSID "Menu strings" {
/* [   ] */		"Test"
/* [   ] */		"DG Functions^10000"
/* [  1] */			"Fill Settings^EL^10000"
/* [  2] */			"Library Browser^EL^10080"
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

dushyant
Enthusiast
I am also facing the same issue - not able to get the icon at that level. And looking at ArchiCAD's default menus, icons are visible at that level. So it seems it should be possible..

Ralph Wessel
Mentor
I don't think the API allows you to set the icon for the parent item of a sub-menu
Ralph Wessel BArch

Solution
Martin Walter
Enthusiast
I finally solved the problem for me.
The indexes are the problem. It is not working this way:
'STR#' ID_MENU_STRINGS_NEW "Menu strings" {
/* [    ] */		"Planersoftware 2.0"
/* [  1] */		"Erstelle neues Fenster oder Tür^32101"
}
But this way:
'STR#' ID_MENU_STRINGS_NEW "Menu strings" {
/* [  1] */		"Planersoftware 2.0"
/* [  2] */		"Erstelle neues Fenster oder Tür^32101"
}
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

dushyant
Enthusiast
Hi Martin,
I just tried indexing your way (starting from 1 for the main menu), but I'm still not getting the menu-icon.

Dushyant Basson

Martin Walter
Enthusiast
Here is a working example for the first menu level.
AC23, Windows 10, i7-6700HQ, 8Gb RAM, 500Gb SSD

dushyant
Enthusiast
In your attached example,
DG_Test.grc has: "DG Functions^10000"
But DG_TestFix.grc has no identifier with 10000.

Ralph Wessel
Mentor
Martin wrote:
The indexes are the problem. It is not working this way:
'STR#' ID_MENU_STRINGS_NEW "Menu strings" {
/* [ ] */ "Planersoftware 2.0"
/* [ 1] */ "Erstelle neues Fenster oder Tür^32101"
}
Those aren't indices – they're just comments. The compiler ignores them, so they could contain nothing or not be there at all. We put them in as an easy visual check when referencing the menu items in code, i.e. ensuring the code aligns to the resources.
Ralph Wessel BArch

dushyant
Enthusiast
What guides the indenting of sub-menus? How to control which sub-menu can further have its own sub-menus?

Ralph Wessel
Mentor
If you're adding a custom menu, the number of items in the resource determines if it's a single menu item of a submenu. If there's only 2 items, the first is the main menu and the second is the menu item. If more than 2, the first is them main menu, the second is the submenu and any additional items are listed under the submenu. You can't nest menus any deeper than that.
For example:

'STR#' 32510  "Nested Menu" {
	"Main Menu"
	"Submenu"
	"Item 1"
	"Item 2"
	"Item 3"
}


'STR#' 32511  "Single Item" {
	"Main Menu"
	"Item 1"
}
The single menu item and submenu above will both appear under the menu "Main Menu".
Ralph Wessel BArch

Anonymous
Not applicable
We have our company standards available in our 'JHP' drop down menu and are able to get an icon at the parent level. One thing we have discovered is that the integer used as the reference for the menu item is of type short with a max value of 32767. Your original example, that did not work, uses 33000. The subsequent examples that do work use 32501, 32101, 10000, etc. - - all less than 32767.

Just a guess...

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!