Hello everyone,
I found a malfunction during the use of the "OnChange" event in a control. I am referring to the HMG 3.0.35. I've attached an example that generates the error and this is the error.
Also, are indicative only for those who are developing HMG 4, I found that the use of "ONMOUSECLICK Nil" (when defining a form) crash the program.
Best regards.
onchange event on a control
Moderator: Rathinagiri
onchange event on a control
- Attachments
-
- OnChange.zip
- example
- (1.73 KiB) Downloaded 304 times
Luigi from Italy
www.L3W.it
www.L3W.it
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: onchange event on a control
Ciao Luigi
Please try this :
And please don't ask me "why?",
because I don't know; simply tried and succeed (error gone away)
Regards
--
Esgici
Please try this :
Code: Select all
/***********************************************************
* calculate
***********************************************************/
STATIC FUNCTION Win1_Calculate()
IF IsControlDefined( Win1Frm, nfield01 )
Win1Frm.nfield03.Value := Win1Frm.nfield01.Value + Win1Frm.nfield02.Value
ENDIF
RETURN NIL
because I don't know; simply tried and succeed (error gone away)
Regards
--
Esgici
Viva INTERNATIONAL HMG
Re: onchange event on a control
Hi Esgici,
many thanks for your quickly replay ...but I know this solution (I've used a similar solution in my app).
I think, but I'm not sure, can be the events order activation after (and not before ) form definition.
Best regards
many thanks for your quickly replay ...but I know this solution (I've used a similar solution in my app).
I think, but I'm not sure, can be the events order activation after (and not before ) form definition.
Best regards
Luigi from Italy
www.L3W.it
www.L3W.it
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: onchange event on a control
I'm not sure, but I'm thinking that way :
ACTIVATE command always triggered all ON CHANGE procs/blocks BEFORE (?) activation
Ciao
--
Esgici
ACTIVATE command always triggered all ON CHANGE procs/blocks BEFORE (?) activation
Ciao
--
Esgici
Viva INTERNATIONAL HMG
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: onchange event on a control
Hi Luigi,
It is possible to fire the change event even before activation of window. Actually it is what happening here.
You have hooked the on change event of nfield01. When the value is changed, it refers to nfield02, and nfield03 which were not at all defined at that time! That is why the error is occuring.
Actually Setting an INPUTMASK to a textbox changes its value to 0.
So, it is safe to check whether the other controls (or the last control) are defined.
It is possible to fire the change event even before activation of window. Actually it is what happening here.
You have hooked the on change event of nfield01. When the value is changed, it refers to nfield02, and nfield03 which were not at all defined at that time! That is why the error is occuring.
Actually Setting an INPUTMASK to a textbox changes its value to 0.
So, it is safe to check whether the other controls (or the last control) are defined.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: onchange event on a control
Hello to everyone and thanks for your interest.
I think, given the response of Rathi, are confirmed my doubts about the activation sequence of events.
Obviously, the solution is that you proposed, but I think (let me ) that it is "wrong".
I think the cycle should respect the sequence: definition of the form, the form events, events for controls (in the order in which they were defined on the form). Only if the form has been completely defined I can trigger an event like onchange.
But this is My Humble Opinion
Anyway thanks for your answers .
I think, given the response of Rathi, are confirmed my doubts about the activation sequence of events.
Obviously, the solution is that you proposed, but I think (let me ) that it is "wrong".
I think the cycle should respect the sequence: definition of the form, the form events, events for controls (in the order in which they were defined on the form). Only if the form has been completely defined I can trigger an event like onchange.
But this is My Humble Opinion
Anyway thanks for your answers .
Luigi from Italy
www.L3W.it
www.L3W.it