How to Add Code to Wizard-Generated Command Buttons (134790)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Macintosh 3.0b

This article was previously published under Q134790

SUMMARY

You can add code to command buttons created by the Form Wizard and still have the command buttons function properly.

MORE INFORMATION

The command buttons created by the Form Wizard are based on classes defined in the Vfp\Wizards\Wizstyle.vcx visual class library.

All of the command buttons are contained in one of three classes, depending on which style of buttons was used:
class Name      Button Style
--------------------------------
txtbtns         Horizontal; text
verttxtbtns     Vertical; text
picbtns         Horizontal; picture
				
Each button is assigned an individual name, following recommended Visual FoxPro naming conventions:

cmdPrev
cmdNext
cmdTop
cmdEnd
cmdFind
cmdPrint
cmdAdd
cmdEdit
cmdDelete
cmdExit

The code for each button is contained in the class definition, not in each button on the form. If method code is entered in an event, such as the click event, which also has code defined in the parent class, the new code will override the parent class code. The parent class code must be explicitly called within the method.

You can add code to the buttons in a generated screen, as long as the code in the parent class is called using the scope resolution operator, as in this example:
   txtbtns.cmdAdd::Click
   WAIT WINDOW "I just called the parent click code"
				
If you want the additional code to be processed prior to the default button behavior, place it before the line that calls the parent method. If you want the additional to be processed after the default button behavior, place it after the line that calls the parent method.

Modification Type:MajorLast Reviewed:10/15/2003
Keywords:KB134790