cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.

Is there a way to create controls programmatically

Anonymous
Not applicable
Hi

I want to create a several listview control programmatically depend on API information.
Is there a way to do that without writing something in .grc resource file ?

How I can do this ?

Thanks in advance.
1 REPLY 1
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
Hi ggiloyan,

Sure, you can add dynamically new dialog items to your dialog using DGAppendDialogItem function.

Here's a short example how to create new ListView control to your dialog:
listInd = DGAppendDialogItem (dialID, DG_ITM_LISTVIEW, DG_LVT_SINGLESELECT, 0, x, y, dx, dy); 
if (listInd == 0) { 
	ACAPI_WriteReport ("Failed to create ListView!", true); 
} else { 
	DGSetItemFont (dialID, listInd, DG_IS_SMALL | DG_IS_PLAIN); 
	DGListViewSetItemSize (dialID, listInd, itemWidth, itemHeight); 
	DGShowItem (dialID, listInd); 
 
	for (short i = 0; i < nItems; i++) { 
		DGListViewInsertItem (dialID, listInd, DG_LIST_BOTTOM); 
		DGListViewSetItemText (dialID, listInd, DG_LIST_BOTTOM, GS::UniString::Printf ("ListView item #%d", i)); 
	} 
}

Of course to make space to your new controls you should resize your dialog using DGSetDialogSize or move other controls.

You can find many useful functions in DG.h header file.

Regards,
Tibor