Page 1 of 1

HMG4 event idea

Posted: Thu Mar 03, 2011 4:53 pm
by l3whmg
Hello everyone, I would like to have your opinion on whether to add two events to the form.

The names could be: "OnBeforeShow" and "OnAfterShow".
These two events would be triggered immediately before and after the statement "oQTObject: Show ()" in window.prg.

The reasons for this request is: often, it is useful to fill in the fields after a processing or perform a procedure, etc.
Since the form is not yet completely loaded I get errors

Another example that comes to me is this: in the OnInit function of the main form, I have to open another form. Based on the result of this operation I have to figure out whether to continue or not. With Hmg4 I have problems, but using the assumed event OnAfterShow everything works fine.

What do you think about this idea?

Best regards.

Re: HMG4 event idea

Posted: Thu Mar 03, 2011 6:59 pm
by Rathinagiri
Hi Luigi,

Kindly create the code along with some samples to demonstrate the same. Definitely your suggestion will be useful to all.

Thanks.

Re: HMG4 event idea

Posted: Thu Mar 03, 2011 7:37 pm
by esgici
l3whmg wrote: ...
What do you think about this idea?
...
Hi Luigi

Good idea :idea:

Please continue :)

Regards

--

Esgici

Re: HMG4 event idea

Posted: Fri Mar 04, 2011 1:14 pm
by l3whmg
Hi guys,
Today it's not a good day..... I've written code but without good news :oops:

In fact, HMG4 have different core from HMG3: when you change a value inside OnInit event and other field depend by OnChange clause of this, with HMG3 you can receive error. with HMG4 no :D

I was hoping to find a way to see or do something immediately after the appearance of the form on the video, but without result. In according with documentation provided by QT, I created an event OnAfterShow, but I get the same result with the OnInit event. bAfterEvent first runs and then you see the form. In fact, putting a trivial MsgStop, I see the message first and then I see the form.

Anyway, this is a piece of code for windows.prg

Code: Select all

/*----------------------------------------------------------------------*/    //L3W
METHOD OnAfterShow( bValue ) CLASS WINDOW                                     //L3W
                                                                              //L3W
   IF ::lCreated                                                              //L3W
      IF PCOUNT() == 0                                                        //L3W
         RETURN ::bOnAfterShow                                                //L3W
      ELSEIF PCOUNT() == 1                                                    //L3W
         ::bOnAfterShow := bValue                                             //L3W
         IF .NOT. ::oQTObject:connect( QEvent_Show , {||EVAL( bValue ) } )    //L3W
            ::oQTObject:disconnect( QEvent_Show )                             //L3W
            IF .NOT. ::oQTObject:connect( QEvent_Show , {||EVAL( bValue ) } ) //L3W
               // Error                                                       //L3W
            ENDIF                                                             //L3W
         ENDIF                                                                //L3W
      ENDIF                                                                   //L3W
   ELSE                                                                       //L3W
      IF PCOUNT() == 0                                                        //L3W
         RETURN ::bOnAfterShow                                                //L3W
      ELSEIF pcount() == 1                                                    //L3W
         ::bOnAfterShow := bValue                                             //L3W
      ENDIF                                                                   //L3W
   ENDIF                                                                      //L3W
                                                                              //L3W
   RETURN NIL                                                                 //L3W
And this was translation command to use with DEFINE WINDOW

Code: Select all

#xcommand ONAFTERSHOW         <bvalue>  =>   :OnAfterShow         := <{bvalue}>
If someone have a better idea....

Best regards