BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

Innactive controls in docked pallete

Anonymous
Not applicable
Hello Archicad developers!

I have an issue with a plugin which I'm developing for the windows version of Archicad 21.

The actual issue is that I have a dockable palette, created with DGCreateDockablePalette, which contains Icons and every Icon calls a function. If the palette is a free floating window when I click each Icon it calls the corresponding function, but I If dock my palette somewhere my Icons don't seem to work anymore. What could be the possible reason for this?

Also I have my plugin already working for the MacOS version of Archicad 21 and there isn't any problem with my palette, no matter if its docked or not.

Here is some of my code which calls the palette:

GSErrCode __ACENV_CALL MenuCommandHandler(const API_MenuParams *menuParams)
{


	if (menuParams->menuItemRef.menuResID == 32500) {
		GSErrCode errorCode = ACAPI_CallUndoableCommand("Importer",
			[&]() -> GSErrCode {

			switch (menuParams->menuItemRef.itemIndex) {
				//case  1: openWebView(); break;
			case 1: Do_PaletteInit(); break;
				//case  2: importFiles();break;
				//case  3: updateBuildups();break;

			default: return NoError;
			}
		});

		return errorCode;
	}
	return NoError;
}

// -----------------------------------------------------------------------------
// Dependency definitions
// -----------------------------------------------------------------------------
API_AddonType __ACENV_CALL	CheckEnvironment(API_EnvirParams* envir)
{
	//
	// Fill in the necessary information
	//
	RSGetIndString(&envir->addOnInfo.name, 32000, 1, ACAPI_GetOwnResModule());
	RSGetIndString(&envir->addOnInfo.description, 32000, 2, ACAPI_GetOwnResModule());

	//
	// Register command services
	//
	GSErrCode err = ACAPI_Register_SupportedService('ABCD', 4L);
	if (err != NoError)
		return APIAddon_DontRegister;

	return APIAddon_Normal;
}		/* RegisterAddOn */


		// -----------------------------------------------------------------------------
		// Interface definitions
		// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL	RegisterInterface(void)
{
	GSErrCode	err;

	//
	// Register menus
	//
	//err = ACAPI_Register_Menu (32500, 0, MenuCode_UserDef, MenuFlag_SeparatorBefore);
	err = ACAPI_Register_Menu(32500, 0, MenuCode_Palettes, MenuFlag_SeparatorBefore);

	return err;
}		/* RegisterInterface */


		// -----------------------------------------------------------------------------
		// Called when the Add-On has been loaded into memory
		// to perform an operation
		// -----------------------------------------------------------------------------
GSErrCode __ACENV_CALL	Initialize(void)
{

	GSErrCode err = NoError;
	static short result = 0;

	//
	// Install menu handler callbacks
	//
	err = ACAPI_Install_MenuHandler(32500, MenuCommandHandler);

	return err;

	//return err;
}		/* Initialize */


		// -----------------------------------------------------------------------------
		// Called when the Add-On is going to be unloaded
		// -----------------------------------------------------------------------------

GSErrCode __ACENV_CALL	FreeData(void)
{
	return NoError;
}		/* FreeData */


static short   myDialID = 0;

static GSErrCode __ACENV_CALL   PaletteAPIControlCallBack(Int32 referenceID, API_PaletteMessageID messageID, GS::IntPtr /*param*/)
{
	if (referenceID == myDialID) {
		switch (messageID) {
		case APIPalMsg_ClosePalette:      break;
		case APIPalMsg_HidePalette_Begin:   break;
		case APIPalMsg_HidePalette_End:      break;
		case APIPalMsg_DisableItems_Begin:
		case APIPalMsg_DisableItems_End:   // actually do nothing, because the input finish functionality the buttons have to stay enabled
		case APIPalMsg_IsPaletteVisible:
		case APIPalMsg_OpenPalette:         break;
		}
	}

	return NoError;
}

const short CloseButtonID = 1;
const short UpdateButtonID = 2;

static short DGCALLBACK CntlDlgCallBack(short message, short dialID, short item, DGUserData /*userData*/, DGMessageData msgData)
{
	OutputDebugString("CntlDlgCallBack");

	switch (message) {
		
	case DG_MSG_INIT:
		DGSetFocus(dialID, DG_NO_ITEM);

		if (ACAPI_RegisterModelessWindow(dialID, PaletteAPIControlCallBack,
			API_PalEnabled_FloorPlan + API_PalEnabled_Section + API_PalEnabled_Elevation +
			API_PalEnabled_InteriorElevation + API_PalEnabled_Detail + API_PalEnabled_Worksheet + API_PalEnabled_3D + API_PalEnabled_Layout) != NoError)
			DBPrintf("ACAPI_RegisterModelessWindow failed\n");
		break;

	case DG_MSG_ACTIVATE:      break;
	case DG_MSG_UPDATE:         break;
	case DG_MSG_CHANGE:         break;
	case DG_MSG_DOUBLECLICK:   break;

	case DG_MSG_CLICK:
		switch (item) {
			
		case 1:   openWebView("sg"); break;
		case 2:   openWebView("search"); break;
		case 3:   openWebView("favourites"); break;
		case 4:   openWebView("messages"); break;
		case 5:   openWebView("settings"); break;
		case 6:   ACAPI_CallUndoableCommand("importFiles", [&]() -> GSErrCode { importFiles(); return (0); });


		case DG_CLOSEBOX:
			return item;   // this will result in a DG_MSG_CLOSE message
		}
		break;

	case DG_MSG_GROW:
	{
		short   vgrow = DGGetVGrow(msgData);
		short   hgrow = DGGetHGrow(msgData);
		DGBeginMoveGrowItems(dialID);
		//DGMoveItem (dialID, NavCloseButton, hgrow, vgrow);
		//DGMoveItem (dialID, NavUpdateButton, hgrow, vgrow);
		DGEndMoveGrowItems(dialID);
	}
	break;

	case DG_MSG_CLOSE:
		ACAPI_UnregisterModelessWindow(myDialID);
		myDialID = 0;
		break;

	default:
		break;
	}

	return (0);
}      // CntlDlgCallBack

static GS::Guid dialogGUID("{9597C98D-95BD-48d9-9999-C2297834806B}");

static bool      Do_PaletteInit(void)
{	

	if (myDialID == 0 || !DGIsDialogOpen(myDialID)) {
		//myDialID = DGModelessInit (ACAPI_GetOwnResModule (), 32400, ACAPI_GetOwnResModule (), CntlDlgCallBack, NULL, 1);
		myDialID = DGCreateDockablePalette(ACAPI_GetOwnResModule(), 32400, ACAPI_GetOwnResModule(), CntlDlgCallBack, NULL, dialogGUID);
	}
	

	DGBeginProcessEvents(myDialID);
	DGShowModelessDialog(myDialID, 0);


	return myDialID != 0;
}      // Do_PaletteInit



2 REPLIES 2
Anonymous
Not applicable
I have found the problem - when I replace the Icon with Button it seems to work. So now the question now is can I have buttons with images inside of them ?
Anonymous
Not applicable
The problem is solved by using IconButton, which wasn't needed in MacOS.
Learn and get certified!

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!