Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bug in wizard txtbtn
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00052053
Message ID:
00052553
Views:
31
>Dang, I just wrote another book. Well, it's the core of our frameworks. Care to comment?
Bret,

Only a brief comment from me <g>.

First the reason to define the buttons separately is that they can then be combined into different containers in different configurations without need to modify any code. Now I agree that the buttons should not have code in them that really does anythijng, they should be calling methods of the form and the form shouldb e doing the stuff. This approach lets you decide to use buttons in the form or buttons in a toolbar or hot keys in a menu or buttons on the telephone or light switches on the wall. You don't need to make these decisions right away and you can easily change them later. This approach is called delegation, as the buttons delegate responsibility for the behavior to the form.

Why define the buttons external and separately, well because you can never remove anything form a parentclass in a subclass, therefore if you want to have multiple configrations of buttons you need to have multiple container classes that have those configurations. These containers should not superclass - subclass related but rather they should all be sibling classes at the same level in the hierarchy. By having a cmdTop, cmdNext, cmdPrior,cmdBottom,cmdEdit, cmdAdd, cmdSave,cdmRevert,cmdExit, etc. buttons all fully functional, you can then create seveal containers each having a diffeent combination of these button classes in them. The code for the button classes is not duplicated, it appears only once in the button class definition. If you decide someday that you want a cmdEditFlashing that makes the whole screen flash wduring the eidt, you can subclass the cmdEdit button and modify its behavior. You cannot do this if the buttons are defined as part of the container (like in Wizstyle.vcx).

Also modifying behavior in the object is much easier, if you want to add a message box to the cmdDelete button in one fomr you can just edit the click event for that button in that form and;

* cmdDelete Click
IF Messagebox(...) = IDYES
cmdDelete::Click()
ENDIF

instead of;

*cmddelete click
IF messagebox ...
txtBtns.cmdDelete::Click()
ENDIF

You see with the early composition (meaning before the code is in the button classes, you have to idnetify the button as a member of the container. But with late composition (the code exists in a button class before it was added to teh container) you only need to identify the button class.

Hope this give you some ideas.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform