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!

ButtonClicked function do not work.

Soonbum Jeong
Newcomer
Dear developers,

I finished writing UI resource code.
But event handle working has difficult now.

Next code is current working.
In the ButtonClicked function,
if (ev.GetSource () == &btn_OK) {
These codes are not working.
}

Could you answer me about the cause?

Environment : Windows 7 64Bit, ArchiCAD 19, API v19


class placeEuroformDialog :	public DG::ModalDialog,
							public DG::ButtonItemObserver,
							public DG::CompoundItemObserver
{
protected:
	enum Controls {
		ButtonID		= 1,
		GroupboxID		= 2,
		LeftTextID		= 3,
		IntEditID		= 4,
		PopupControlID	= 5
	};

	DG::Button		btn_OK;
	DG::Button		btn_Cancel;
	DG::GroupBox	grp_placeCnt;
	DG::GroupBox	grp_euroformOptions;
	DG::LeftText	lbl_horCnt;
	DG::LeftText	lbl_verCnt;
	DG::LeftText	lbl_wid;
	DG::LeftText	lbl_hei;
	DG::LeftText	lbl_ori;
	DG::LeftText	lbl_inst;
	DG::IntEdit		edt_horCnt;
	DG::IntEdit		edt_verCnt;
	DG::PopUp		popup_wid;
	DG::PopUp		popup_hei;
	DG::PopUp		popup_ori;
	DG::PopUp		popup_inst;

	virtual void	ButtonClicked (const DG::ButtonClickEvent& ev) override;

public:
	placeEuroformDialog ();
	~placeEuroformDialog ();
};

placeEuroformDialog::placeEuroformDialog () :
		DG::ModalDialog		(ACAPI_GetOwnResModule (), 32600, ACAPI_GetOwnResModule ()),
		btn_OK				(GetReference (), ButtonID),
		btn_Cancel			(GetReference (), ButtonID),
		grp_placeCnt		(GetReference (), GroupboxID),
		grp_euroformOptions	(GetReference (), GroupboxID),
		lbl_horCnt			(GetReference (), LeftTextID),
		lbl_verCnt			(GetReference (), LeftTextID),
		lbl_wid				(GetReference (), LeftTextID),
		lbl_hei				(GetReference (), LeftTextID),
		lbl_ori				(GetReference (), LeftTextID),
		lbl_inst			(GetReference (), LeftTextID),
		edt_horCnt			(GetReference (), IntEditID),
		edt_verCnt			(GetReference (), IntEditID),
		popup_wid			(GetReference (), PopupControlID),
		popup_hei			(GetReference (), PopupControlID),
		popup_ori			(GetReference (), PopupControlID),
		popup_inst			(GetReference (), PopupControlID)
{
	AttachToAllItems (*this);
}

placeEuroformDialog::~placeEuroformDialog ()
{
	DetachFromAllItems (*this);
}

void placeEuroformDialog::ButtonClicked (const DG::ButtonClickEvent& ev)
{
	ACAPI_WriteReport ("This message is show.", true);

	if (ev.GetSource () == &btn_OK) {
		ACAPI_WriteReport ("OK Button... This message is not show.", true);
		PostCloseRequest (Accept);
	}
}

...

GSErrCode	placeEuroform (void)
{
	placeEuroformDialog	dialog;
	dialog.Invoke ();

	return NoError;
}

...

GSErrCode __ACENV_CALL	MenuCommandHandler (const API_MenuParams *menuParams)
{
	GSErrCode	err = NoError;

	switch (menuParams->menuItemRef.menuResID) {
		case 32500:
			switch (menuParams->menuItemRef.itemIndex) {
				case 1:		err = placeEuroform ();		break;
			}
			break;
	}

	return err;
}		// CommandHandler ()
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Oleg
Expert

ButtonID		= 1,
		
btn_OK				(GetReference (), ButtonID),
btn_Cancel			(GetReference (), ButtonID),

Each control must have a unique number (ID) exactly equal to the position in the 'GDLG' resource.

View solution in original post

2 REPLIES 2
Solution
Oleg
Expert

ButtonID		= 1,
		
btn_OK				(GetReference (), ButtonID),
btn_Cancel			(GetReference (), ButtonID),

Each control must have a unique number (ID) exactly equal to the position in the 'GDLG' resource.
Soonbum Jeong
Newcomer
Dear Oleg,

Your answer is exactly right.
My source code did not have "unique" ID.
After fixed code, my code works well.
Thank you, Oleg.