The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How to refresh the change made by Apply button?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

zhaokf

USA
5 Posts

Posted - 03/06/2006 :  05:54:04 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
sorry, I posted same message on the origin forum before I realize this is which it should go.
--------------------------------------------------------------------------------
Origin Version (Select Help-->About Origin): 7.5
Operating System: winxp pro

I try to change the value of some treenodes in the event handling function of the apply button, but the getnbox dialog doesn't update displayed value at all, although the actually value has already been changed seen from the debug window.

Further more, if I move the focus into the edit area and move it out without making any change. The dialogchangeevent function will be triggered, since origin now sees the displayed value is different from the actually value.

What can I do to let the change made in the Apply function be displayed?

Mike Buess

USA
3037 Posts

Posted - 03/06/2006 :  1:56:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

zhaokf

USA
5 Posts

Posted - 03/07/2006 :  3:09:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot, Mike.

I don't know that Apply button is not a event handler. I was misled by the origin help on the Apply button:

"To add an Apply button to a GetN dialog box, ... The Apply button function should return a value of type bool equal to:
true if the dialog needs to be refreshed (for example, if the Apply function changes the value of a control on the dialog).

false if the dialog does not need to be refreshed"

I hope this can be realized in the next version.

However, your 2nd example suggested me a way to work around. I will stop using the Apply button, but, instead, add a TreeNode using

GETN_BUTTON(Apply,"Apply","Apply")
GETN_OPTION_EVENT(OnButton)

to the end of the tree, and move all the code that was meant to be executed by the Apply button to the event handler of the this Button, so that not only the main function can be carried out, but also any changes made on the tree can be refreshed.

Your comments?

Kaifeng
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/07/2006 :  5:35:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
GETN_BUTTON(Apply,"Apply","Apply")
GETN_OPTION_EVENT(OnButton)
That was what I had in mind when I gave the 2nd example. The only drawback to this approach is that the button is hidden unless you click on its field.

Mike Buess
Origin WebRing Member
Go to Top of Page

zhaokf

USA
5 Posts

Posted - 03/08/2006 :  04:32:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It's ok , since i'm the only one using my program. I think dialog builder might be the ultimate way to do these user interface jobs. But I still like the getnbox a lot, it's so handy and yet powerful. I really wish Origin can strengthen the Apply Button a bit more.
Anyway, many thanks for your help.

kaifeng
Go to Top of Page

easwar

USA
1965 Posts

Posted - 03/08/2006 :  2:43:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

But I still like the getnbox a lot, it's so handy and yet powerful. I really wish Origin can strengthen the Apply Button a bit more.



Hi Kaifeng,

Thanks for the suggestion. We are working on improving such functionality in the next version.

Easwar
OriginLab

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000