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

DGAppendDialogItem broken?

Anonymous
Not applicable
Hi, I am wondering what you need to do to get DGAppendDialogItem to create an item on a modal dialog. I've tried calling it inside and outside DG_MSG_INIT, tried creating different types of controls, and tried on pre-made dialogs and DGBlankModalDialog. And I haven't yet been able to get a new control to appear.

Is there something special you need to do to get this function to work?

Thanks
3 REPLIES 3
Anonymous
Not applicable
For example, the following code displays a blank dialog box (the button is not added).
static short DGCALLBACK	TestDlgCallBack (short message, short dialId, short itemId, DGUserData /*userData*/, DGMessageData /*msgData*/) {
	switch (message) {
		case DG_MSG_INIT: 
			{
				short newItem = DGAppendDialogItem (dialId, DG_ITM_BUTTON, DG_BT_TEXT, NULL, 5, 5, 20, 20);
				DBPrintf("new item %d added\n", newItem);
			}
			break;
		case DG_MSG_CLOSE:
			break;
		case DG_MSG_CLICK:
			switch (itemId) {
				//case 2: // Close button
				case DG_CLOSEBOX:
					return(1);
					break;
				default:
					break;
			}
		default:
			break;
	}
	return 0;
}

void openTestDlg() {
	DGBlankModalDialog (200, 200, DG_DLG_HGROW | DG_DLG_VGROW, 0, DG_DLG_THICKFRAME, TestDlgCallBack, NULL);
}
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi paulk,

After using DGAppendDialogItem, you should call DGShowItem to make the new item visible:
  // add new item: 
short newItem = DGAppendDialogItem (dialId, DG_ITM_CHECKBOX, DG_BT_TEXT, 0, 206, 7, 60, 18); 

  // set font, text and others: 
DGSetItemFont (dialId, newItem, DG_IS_EXTRASMALL); 
DGSetItemText (dialId, newItem, "NEW"); 
// ...

  // make it visible: 
DGShowItem (dialId, newItem); 


Best,
Tibi
Anonymous
Not applicable
Thanks Tibi

That info should be added to the API documentation.

Paul