We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2019-05-02 09:16 PM - last edited on 2022-10-05 01:28 PM by Daniel Kassai
'STR#' 32500 "Menu strings" { /* [ ] */ "JHP" /* [ ] */ "JHP1" /* [ 1] */ "JHP1A" /* [ 2] */ "JHP1B" /* [ 3] */ "JHP1C" /* [ ] */ "JHP2" /* [ 1] */ "JHP2A" /* [ ] */ "JHP3" /* [ 1] */ "JHP3A" /* [ 2] */ "JHP3B" }
Solved! Go to Solution.
2019-05-03 11:09 AM
'STR#' 32500 "JHP1 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP1" /* [ 1] */ "JHP1A" /* [ 2] */ "JHP1B" /* [ 3] */ "JHP1C" } 'STR#' 32501 "JHP2 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP2" /* [ 1] */ "JHP2A" } 'STR#' 32502 "JHP3 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP3" /* [ 1] */ "JHP3A" /* [ 2] */ "JHP3B" }Then register each successive menu in the same way as the original 32500, but using the relevant resource ID
2019-05-02 09:52 PM
2019-05-02 10:33 PM
// ----------------------------------------------------------------------------- // RegisterInterface // Interface definitions // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL RegisterInterface (void) { GSErrCode err = ACAPI_Register_Menu (32500, 32510, MenuCode_UserDef, MenuFlag_Default); if (err != NoError) ACAPI_WriteReport ("RegisterInterface() ACAPI_Register_Menu failed\n", false); return err; } // RegisterInterface
2019-05-02 11:19 PM
2019-05-03 10:54 AM
2019-05-03 11:09 AM
'STR#' 32500 "JHP1 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP1" /* [ 1] */ "JHP1A" /* [ 2] */ "JHP1B" /* [ 3] */ "JHP1C" } 'STR#' 32501 "JHP2 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP2" /* [ 1] */ "JHP2A" } 'STR#' 32502 "JHP3 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP3" /* [ 1] */ "JHP3A" /* [ 2] */ "JHP3B" }Then register each successive menu in the same way as the original 32500, but using the relevant resource ID
2019-05-03 08:48 PM
Ralph wrote:Ralph's right, you have to create 3 different string table resources for this purpose.
A menu in the API consists of a single title heading up a list of items. It can't contain another heading underneath it.
'STR#' 32500 "JHP1 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP1" /* [ 1] */ "JHP1A" /* [ 2] */ "JHP1B" /* [ 3] */ "JHP1C" } 'STR#' 32501 "JHP2 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP2" /* [ 1] */ "JHP2A" } 'STR#' 32502 "JHP3 menu" { /* [ ] */ "JHP" /* [ ] */ "JHP3" /* [ 1] */ "JHP3A" /* [ 2] */ "JHP3B" }In the C++ code you must register 3 menus in the RegisterInterface function (using MenuCode_UserDef flag) and you can initialize the same callback function for all of your menus in the Initialize function:
GSErrCode __ACENV_CALL RegisterInterface (void) { GSErrCode err = NoError; err = ACAPI_Register_Menu (32500, 0, MenuCode_UserDef, MenuFlag_Default); err = ACAPI_Register_Menu (32501, 0, MenuCode_UserDef, MenuFlag_Default); err = ACAPI_Register_Menu (32502, 0, MenuCode_UserDef, MenuFlag_Default); return err; } GSErrCode __ACENV_CALL Initialize (void) { GSErrCode err = NoError; err = ACAPI_Install_MenuHandler (32500, MenuCommandHandler); err = ACAPI_Install_MenuHandler (32501, MenuCommandHandler); err = ACAPI_Install_MenuHandler (32502, MenuCommandHandler); return err; }Finally your menu command handler function should look something like this:
GSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams* params) { switch (params->menuItemRef.menuResID) { case 32500: { switch (params->menuItemRef.itemIndex) { case 1: JHP1A (); break; case 2: JHP1B (); break; case 3: JHP1C (); break; } break; } case 32501: { switch (params->menuItemRef.itemIndex) { case 1: JHP2A (); break; } break; } case 32502: { switch (params->menuItemRef.itemIndex) { case 1: JHP3A (); break; case 2: JHP3B (); break; } break; } } return NoError; }
2019-05-07 12:46 AM
2019-05-09 10:50 PM
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // in the .grc file // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* Text appearing in the menu */ 'STR#' 32500 "Menu strings" { /* [ ] */ "JHP" /* [ ] */ "JHP1" /* [ 1] */ "JHP1A" /* [ 2] */ "JHP1B" /* [ 3] */ "JHP1C" } 'STR#' 32501 "Menu strings" { /* [ ] */ "JHP" /* [ ] */ "JHP2" /* [ 1] */ "JHP2A" } 'STR#' 32502 "Menu strings" { /* [ ] */ "JHP" /* [ ] */ "JHP3" /* [ 1] */ "JHP3A" /* [ 2] */ "JHP3B" } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // in the main.cpp file // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ----------------------------------------------------------------------------- // Command executed by menu choices // ----------------------------------------------------------------------------- void ShowMessage(char argv[]) { MessageBox(0, argv, "Menu choice made is...", MB_OK); } // ----------------------------------------------------------------------------- // Handles menu commands // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL MenuCommandHandler(const API_MenuParams *menuParams) { switch (menuParams->menuItemRef.menuResID) { case 32500: { switch (menuParams->menuItemRef.itemIndex) { case 1: ShowMessage("1A"); break; case 2: ShowMessage("1B"); break; case 3: ShowMessage("1C"); break; } break; } case 32501: { switch (menuParams->menuItemRef.itemIndex) { case 1: ShowMessage("2A"); break; } break; } case 32502: { switch (menuParams->menuItemRef.itemIndex) { case 1: ShowMessage("3A"); break; case 2: ShowMessage("3B"); break; } break; } } return NoError; } // MenuCommandHandler // ----------------------------------------------------------------------------- // RegisterInterface // Interface definitions // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL RegisterInterface(void) { GSErrCode err = NoError; err = ACAPI_Register_Menu(32500, 0, MenuCode_UserDef, MenuFlag_Default); err = ACAPI_Register_Menu(32501, 0, MenuCode_UserDef, MenuFlag_Default); err = ACAPI_Register_Menu(32502, 0, MenuCode_UserDef, MenuFlag_Default); return err; } // RegisterInterface // ----------------------------------------------------------------------------- // Initialize // Called when the Add-On has been loaded into memory // to perform an operation // ----------------------------------------------------------------------------- GSErrCode __ACENV_CALL Initialize(void) { GSErrCode err = NoError; err = ACAPI_Install_MenuHandler(32500, MenuCommandHandler); err = ACAPI_Install_MenuHandler(32501, MenuCommandHandler); err = ACAPI_Install_MenuHandler(32502, MenuCommandHandler); return err; } // Initialize
2019-05-10 07:35 PM