We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

How to add new Icon button?

RAFD
Participant

Hi,

Does anyone know how to add icon button and image?

Thank you!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Solution

Hi,

You need something like this in your Palette/Dialog resource.

/* [  3] */ IconButton  	216   8	 24  24	10002

The last number is the resource number for the icon which is typically specified in the fixed resource file (RFIX/AddOnFix.grc in a lot of templates).
For example:

#include "ResourceMDIDIds.hpp"

'MDID' 32500 "Add-On Identifier" {
	AC_MDID_DEV /* Developer id. */
	AC_MDID_LOC /* Add-On local id. */
}

'GICN' 10002 "SettingsIcon" {
	"SettingsIcon"
}

If you use the Dialog Manager in C++ style, then you'll need DG::IconButton in your code.

Hope that helps

View solution in original post

Solution
Miha Nahtigal
Advocate

Put your image in RFIX/Images folder.

BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.

View solution in original post

5 REPLIES 5
Solution

Hi,

You need something like this in your Palette/Dialog resource.

/* [  3] */ IconButton  	216   8	 24  24	10002

The last number is the resource number for the icon which is typically specified in the fixed resource file (RFIX/AddOnFix.grc in a lot of templates).
For example:

#include "ResourceMDIDIds.hpp"

'MDID' 32500 "Add-On Identifier" {
	AC_MDID_DEV /* Developer id. */
	AC_MDID_LOC /* Add-On local id. */
}

'GICN' 10002 "SettingsIcon" {
	"SettingsIcon"
}

If you use the Dialog Manager in C++ style, then you'll need DG::IconButton in your code.

Hope that helps

How do I get the image? 

Solution
Miha Nahtigal
Advocate

Put your image in RFIX/Images folder.

BIMquants.comBETA - Quantities and Costs Estimation in Archicad - BETA testers needed.

For example 32612 is for my settings icon and I want to add a refresh icon. How do I get it's number? And do any image in the internet is applicable?

Miklos Vegh
Graphisoft
Graphisoft

HI, you can use arbitrary icon identifier as you like, what matters is that it must be unique in your add-on resource (and must be a positive value in the signed short value range also (eg < 32768)).

How to create image file
You should create a .svg image. This way your icon will be correctly scaled according to the display scale factor. The svg file name must follow a special naming convention. For example in your case if you want an 18x18 pixel size icon it should be 'Refresh_18x18.svg'. Here the name is 'Refresh' and the _18x18 is added to it for the resource compiler system to handle it correctly. Obviously an other icon with size 32x24 would be OtherIcon_32x24.svg and so on.

The svg file can be prepared with Inkscape or an other svg-capable application. Inkscape is freely usable. If you use it there are some rules when drawing AC icons, some of them:

  • Use pixels as unit
  • Do not add pixmaps on the svg canvas
  • Save your image with the 'Save As.../Optimized svg' menu command

Place image to the add-on resource

In the grc file the .svg and the image size extension is omitted, so add the icon name only as mentioned above:

'GICN' 10002 "SettingsIcon" {
	"RefreshIcon"
}

You can load this image to the IconButton either in the resource as a previous comment shows, or you can instantiate a DG::Icon object and set it to a button or an other control.

DG::Icon refreshIcon (resourceModule, 10002);
button.SetIcon (refreshIcon);