The Apply button is not an event handler. It is primarily meant to do the same thing as the OK button using current dialog settings but without closing the dialog. Use a proper event handler to change the dialog settings. The following simple dialog handles all events but you can restrict the events by row number (nRow) or control type (nType). In this case the Apply button merely types the results.void GetNTest1()
{
GETN_TREE(tr)
GETN_NUM(num1,"1st number",0)
GETN_NUM(num2,"2nd number",0)
GETN_NUM(sum,"Sum",0)
if( GetNBox(tr,"Arithmetic",NULL,OnApply,OnEvents) )
{
OnApply(tr);
}
}
bool OnEvents(TreeNode& tr, int nRow, int nType, Dialog& Dlg)
{
tr.sum.dVal = tr.num1.dVal + tr.num2.dVal;
return true;
}
bool OnApply(TreeNode& tr)
{
printf("%g + %g = %g\n",tr.num1.dVal,tr.num2.dVal,tr.sum.dVal);
return true;
}
...You can also use GETN_BUTTON to change the dialog settings since it works like an event handler.void GetNTest2()
{
GETN_TREE(tr)
GETN_NUM(num1,"1st number",0)
GETN_NUM(num2,"2nd number",0)
GETN_BUTTON(sum,"Sum","0")
GETN_OPTION_EVENT(OnButton)
if( GetNBox(tr,"Arithmetic",NULL,NULL,NULL) )
{
printf("%g + %g = %g\n",tr.num1.dVal,tr.num2.dVal,tr.sum.dVal);
}
}
bool OnButton(TreeNode& tr, int nRow, int nType, Dialog& Dlg)
{
tr.sum.strVal = tr.num1.dVal + tr.num2.dVal;
return true;
}
Mike Buess
Origin WebRing Member
Edited by - Mike Buess on 03/06/2006 2:13:30 PM