Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Add these buttons to a form and compile and execute the form. Click on both buttons. They both display a message saying 'Hello':Image Removed

Image Added

Image RemovedImage Added

In other words the redefined method which would display the message 'Bye' is not used for Button 4 because the Click event defined in Button 3 invokes the method in the component where it is defined (#Com_Owner):
INVOKE method(#com_owner.methodone)
Next change the invoke command in the Click event of Button 3 to use #Com_Self instead of #Com_Owner so that the Click event invokes the method in the component where the event is executed:
INVOKE method(#com_self.methodone)
Compile Button 3 and execute your form again. This time when you click on Button 4, the redefined method is used and the message 'Bye' is displayed:

Image RemovedImage Added

#Com_Ancestor
If you want to invoke a method in an ancestor component, you can refer to it by qualifying the name of the method using the generic name #com_ancestor.
For example, to continue with the above example, you can invoke the MethodOne method in Button 3 from the redefined MethodOne in Button 4 like this:
MTHROUTINE name(MethodOne) options(*redefine)
INVOKE method(#com_ancestor.methodone)
USE builtin(MESSAGE_BOX_SHOW) with_args(OK OK INFO '' 'Bye') to_get(#STD_OBJ)
ENDROUTINE
Compile Button 4 and run your test form. When you click on Button 4 first the MethodOne from the ancestor Button 3 is invoked:

Image RemovedImage Added

And then when you click OK, the Message_Box_Show Built-In Function showing the text 'Bye' defined in Button 4 is displayed:Image Removed

Image Added