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

Custome value User control

Anonymous
Not applicable
Hello!

I need to make custom value list and choosing one of values from list add it to one of object parameter. User Control seems to work only on defined list, color line e.t.c.

PopupControl seems to work similar, but didn't understand how to use them from documentation of "Pop-up Control". I did get PopUpControl to show at my dialog window now i need to add values to it.

Any help will be appreciated.
9 REPLIES 9
Anonymous
Not applicable
Maybe someone have example of using PopUpControls?

Found popupcontrol menu in APIOutputFramework_Test from examples.
But couldn't implement it to my dialog menu.
Anonymous
Not applicable
Somehow managed to get it work, not the way i wanted, but it works, at least it seems that way.

On click modal dialog generates new dialog with popup controls.. although not sure how

I'm gonna post if i have any issues and have more precise questions to ask.
Anonymous
Not applicable
DG::PopUp							databasePopup; 
int SelectedIndex = databasePopup.GetSelectedItem();


Hello,

I get selected PopUp menu item after closing ModalDialog, but i need to get chosen item reach time it has been changed in PopUp menu inside ModalDialog.

I belive i need to make PopUp menu observer but i don't know how to make one.
Oleg
Expert
Rinovo wrote:
Maybe someone have example of using PopUpControls?
Below is cutted source code.
( It is a TabPage, not a ModalDialog )

class TabAuxLogItem
	: public DG::TabPage
	, private DG::PopUpObserver
{
public:

	TabAuxLogItem( const DG::TabControl& tabControl, short tabItem=1 );
	~TabAuxLogItem();

private:
	
	virtual void	PopUpChanged (const DG::PopUpChangeEvent& ev);

private:
	DG::PopUp			mi_prf;
};

TabAuxLogItem::TabAuxLogItem( const DG::TabControl& tabControl, short tabItem )
	: DG::TabPage( tabControl, tabItem, ACAPI_GetOwnResModule(), RTAB_AUXL_ITEM, ACAPI_GetOwnResModule() )
	, mi_prf( GetReference(), PRF )
{
	mi_prf.Attach( *this );
}

TabAuxLogItem::~TabAuxLogItem()
{
	mi_prf.Detach( *this );
}

void TabAuxLogItem::PopUpChanged (const DG::PopUpChangeEvent& ev)
{
	if ( ev.GetSource() == &mi_prf )
	{
		UID id = (UID)mi_prf.GetItemValue( mi_prf.GetSelectedItem() );
		UpdateProfileID( id );
	}
}
Anonymous
Not applicable
this->m_comboModels defined in .h file
like this
DG::PopUp			m_comboModels;
in your cpp file you can fill it by this way
this->m_comboModels.DeleteItem(DG::PopUp::AllItems);
for (int i = 0; i < <your array>; i++)
{
	this->m_comboModels.AppendItem();
	this->m_comboModels.SetItemText (DG::PopUp::BottomItem, GS::UniString::Printf("%s", <display member>));
	this->m_comboModels.SetItemValue (DG::PopUp::BottomItem, <value member>);
}
If you need to catch on selected change event of your popup control then you should inherit your dialog or pallete class from public DG::PopUpObserver

and use like this

.h
void	PopUpChanged(const DG::PopUpChangeEvent& e);
.cpp
void PopUpChanged(const DG::PopUpChangeEvent& e)
{ 
	Int32 selValue = TruncateTo32Bit(e.GetSource()->GetItemValue(this->m_comboModels.GetSelectedItem ()));
}
Anonymous
Not applicable
Thanks Oleg, thanks Ggiloyan!

Got it working now
Anonymous
Not applicable
Now i have different problem.

IconPushRadio Buttons haven't got icon. I changed my modal dialog from DGLCALLBACK structure to observer structure. And now i don't have Icon for radio Buttons.
GRC:
 IconPushRadio		  8   22   52   52  1	 32107

.hpp
RadioOneID = 4, 
/... 
DG::IconPushRadio			        RadioOne;

.cpp
RadioOne	    (GetReference (),RadioOneID)


As i was writing this found a way to initialize icon with
RadioOne.SetIcon(DG::Icon(ACAPI_GetOwnResModule (),32106 ));


Previously SetIcon had errors using with pointers and DG::Icon class, solved them just now.

This is only way to get Icons, or is it a bug ? Or i might have other errors ?
Oleg
Expert
IconPushRadio will show an icon from GRC by default.
Use SetIcon if you need to change it only.

Make sure the icon GRC text valid and correct icon's ID.
In you example is 32107 or 32106 correct.

Addition:
Make sure you pass valid parameters to ModalDialog constructor.
See ACAPI_GetOwnResModule() as 1 and 3 parameter.
: ModalDialog( ACAPI_GetOwnResModule(), RDLG_ABOUT, ACAPI_GetOwnResModule() )
Anonymous
Not applicable
Thanks, Oleg!

My constructor didn't had ACAPI_GetOwnResModule() as 3rd parameter.
Now everything works like it should.

Thanks again, Oleg.