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

User control UC257

Anonymous
Not applicable
Hello!

   
DGModalDialog (ACAPI_GetOwnResModule (), UserControl, ACAPI_GetOwnResModule (), UserControl_Handler, (DGUserData) &numItems);

When UserControl is initialized like this it works.
But i need to initialize it into my Modal dialog.
DG::ModalDialog (ACAPI_GetOwnResModule (), dialogResId, ACAPI_GetOwnResModule()),

But when opening userControl data menu data doesn't apear.

I tried to do like this :
UC257SetUserData (dialogID, Itm, (DGUserData)&numItems);   
			UC257SetCallBack (dialogID, Itm, UserControlCallBack);   
			DGSetItemValLong (dialogID, Itm, 1);

CallBack seems to work, when i try to open menu it initializes but somewhere in middle of setting data it doesn't work.

Problem might be somewhere in callBack. Not sure why it worked in DGModalDialog and not in DG::ModalDialog.

CallBack:
   
void CCALL	UserControlCallBack (UC257CallBackRec* callBackRec)   
{   
	if (callBackRec->action == ACT_GETLISTSIZE || callBackRec->action == ACT_GETITEMSIZE)   
		FillGetListSize (callBackRec, false);   
	else if (callBackRec->action == ACT_GETLIST || callBackRec->action == ACT_GETITEM)   
		FillGetList (callBackRec, false);   
	   
	   
	return;   
}   


callBackRec is giving errors not sure why and how does it works
3 REPLIES 3
Oleg
Expert
Actually It is wrong to mix C++ DG classes and plain C DG module functions.

Below is cutted source code of UC257 usage as a Pen control.
Note the ACAPI_Interface ( APIIo_SetUserControlCallbackID ) function, API_UCCallbackType struct, API_UserControlType enum. It is for AC standard lists like Pen, LineType etc. Full

More:
Look the DG_Test example of AC19 API
BuildingMaterialObserver class in BuildingMaterialDialog.hpp and cpp.
I dont study this example but I think it will basically same in more details.

...
#include "UCModule.hpp"
...

class TabWallAttrs 
	: public DG::TabPage 
	, private DG::UserControlObserver
{
public:

...

private:

	virtual void	UserControlChanged (const DG::UserControlChangeEvent& ev);

private:

	UC::UC257		mi_pcont;
};


TabWallAttrs::TabWallAttrs( ... )
	, mi_pconte( GetReference(), PCONTE )
{
	mi_pcont.Attach( *this );

	API_UCCallbackType ct = { APIUserControlType_Pen, GetId(), mi_pcont.GetId() };
	ACAPI_Interface ( APIIo_SetUserControlCallbackID, &ct, NULL );
}

TabWallAttrs::~TabWallAttrs()
{
	mi_pcont.Detach( *this );
}

void TabWallAttrs::UserControlChanged (const DG::UserControlChangeEvent& ev)
{
	if ( ev.GetSource() == &mi_pcont )
	{
	//	mi_pcont.GetValue()
	}
}

Anonymous
Not applicable
Thanks Oleg!

Had defined UserControl under DG::UserControl class but UC::UC257 gives a lot more options.

Got it working now.
Anonymous
Not applicable
Couldn't found a way to show only specific colors/index, access data of UC257.
How could i access and show only specific colors ?
 mi_pcont.Attach( *this ); 

   API_UCCallbackType ct = { APIUserControlType_Pen, GetId(), mi_pcont.GetId() }; 
   ACAPI_Interface ( APIIo_SetUserControlCallbackID, &ct, NULL );