onchange event on a control

Moderator: Rathinagiri

Post Reply
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

onchange event on a control

Post by l3whmg »

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.
image
image
ScreenShot001.jpg (65.46 KiB) Viewed 4422 times
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.
Attachments
OnChange.zip
example
(1.73 KiB) Downloaded 304 times
Luigi from Italy
www.L3W.it
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: onchange event on a control

Post by esgici »

Ciao Luigi

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
And please don't ask me "why?",

because I don't know; simply tried and succeed (error gone away) :(

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: onchange event on a control

Post by l3whmg »

Hi Esgici,
many thanks for your quickly replay :) ...but I know :oops: 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: onchange event on a control

Post by esgici »

I'm not sure, but I'm thinking that way :

ACTIVATE command always triggered all ON CHANGE procs/blocks BEFORE (?) activation :(

Ciao :)

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
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

Post by Rathinagiri »

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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: onchange event on a control

Post by l3whmg »

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 :oops: ) 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 :D .
Luigi from Italy
www.L3W.it
Post Reply