Ecere SDK/eC Forums http://ecere.org/community/ Print view |
|
Question on form.Destroy(0) http://ecere.org/community/viewtopic.php?f=5&t=224 |
Page 1 of 1 |
Author: | samsam598 [ Wed Mar 14, 2012 2:20 am ] |
Post subject: | Question on form.Destroy(0) |
Greetings! I am trying to implement an InputBox function seen in other OO language like VB and Delphi. Code: Select all
InputBox function will open a pop up window,one can enter an integer in the window and then press OK button.After the popup windows closes,the main procedure will receive and make use of this integer value. To make it,It is not difficult actually to me.But I encountered a problem on when the popup windows should be destroyed . My first trial is to place the Destroy(0) in the int InputBox() function body after popup.Modal().But this does not work properly.The popup windows never close. Then I place the Destroy(0) in the OK button's left click event handler right after the int variable 'number' has been modified in the popup windows class.It works,but I am confused now. Code: Select all
1.First trial:in the InputBox() body,the popup window created,opened in modal,read the property number's value and save to variable num,then it is destoryed.I think this is the proper sequence but it turns out it is totally wrong. 2.Second trial:in the button click event body,after the property number was set ,window was destroyed immediately.Now in the InputBox() body,the popup window created,opened in modal,when OK button was pressed,the window destoryed immediately,so how can I read and save the property number's value?I have though this for several times and believe this does not make sence,but it does actually. This is why I am confused.Hope I described the question clear. Thanks for the help. Regards, Sam |
Author: | jerome [ Wed Mar 14, 2012 10:49 am ] |
Post subject: | Re: Question on form.Destroy(0) |
Hi Sam, Modal() does not return until the window has been destroyed (e.g. the dialog is closed). So the Destroy(0) should be in NotifyClicked. Now, in a future version of eC, I want all named instantiations to automatically get a reference count of 1, and be decremented when they go out of scope. But for the moment, local instantiations get a reference count of 0, and do not automatically get decremented when they go out of scope. (Global and member instantiations do however start at 1, and get decremented on module or containing class destruction, which is why making your FormInteger form { } global would solve this issue). What this means is that for now you need to manually incref and decref the form instance when using a local instance: Code: Select all
Code: Select all
Cheers, Jerome |
Author: | samsam598 [ Wed Mar 14, 2012 7:31 pm ] |
Post subject: | Re: Question on form.Destroy(0) |
Clear.Thank you so much for the detailed explanation. What does ButtonCloseDialog do?It is just an user defined buttonClick event handling function? Regards, Sam |
Author: | jerome [ Wed Mar 14, 2012 10:50 pm ] |
Post subject: | Re: Question on form.Destroy(0) |
Hi Sam, ButtonCloseDialog is a button click handling method predefined in the Window class. It destroys the master window with a destroy code of the control's id: Code: Select all
Jerome |
All times are UTC-05:00 | Page 1 of 1 |
Powered by phpBB® Forum Software © phpBB Limited |