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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 How to refresh the change made by Apply button?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
zhaokf Posted - 03/06/2006 : 05:54:04 AM
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?
5   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 03/08/2006 : 2:43:48 PM
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

zhaokf Posted - 03/08/2006 : 04:32:52 AM
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
Mike Buess Posted - 03/07/2006 : 5:35:10 PM
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
zhaokf Posted - 03/07/2006 : 3:09:37 PM
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
Mike Buess Posted - 03/06/2006 : 1:56:40 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000