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:
00052381
Views:
33
>>Back to the discussion, what about the buttons in tastrade model? Sorry, I am really new to VFP and don't know how to tell good and bad class. Can you elaborate on why it is a poor design? If I can't tell what is wrong with wizard buttons, I will probably come out with something as bad. Is there any article or book I can read to help me build this class? I don't have much time because my project schedule is very tight. Any suggestion?
>>
>>Thanks again. UniversalThread is a great place.
>Shih,
>
>There won't be an Unleashed 5.0 book, there wasn't enough new stuff to warrant one. There will be a book for the enxt version but it won't be Unleashed.
>
>As for the wizstyles buttons and what is worng with them. Well this may get complicated, but here goes.
>
>Wizstyle has a class named txtbtns which is acontainer that has buttons in it. The code for the behavior of those buttons is in the buttons in the container. That container is then subclassed into the picbtns class where the pictures are added to the buttons.
>
>This design is what is called composition as the txtbtns class is a container which contains buttons. The problem with this design is that it is difficult to alter the behavior fo the buttons as they don't exist anywhere outside of the container with code. A better design would be to have each button defined as a separate class and then have those buttons combined into the container. This way you could selectively use any of the buttons you like and leave out any you don't want by making other containers with different buttons in them.

I am about to revamp some old code that used txtbtns. I need to rewrite it so I can create a read-only version of my apps, which were not written with a read-only version in mind. The read-only version consists of the same app, with every button that can change the data removed or disabled. The cmdAdd, cmdEdit, and cmdDelete buttons in txtbtns are not needed for a read-only version, but they can't be removed, so I currently set their Visible = .F., which is working fine, but leaves a button bar with funny-looking gaps, and clutters up that version with a lot of code it doesn't need. The trouble is that if I make all the buttons standalone, there will be a lot of repeated code, since the buttons tend to do a lot of the same things. For guidance, I looked at Tastrade. People here say it's a good framework. I found there that their nav buttons are in the tstoolbar class of tsbase.vcx. Each button calls the appropriate method in the form class tsbaseform, which has all the methods a nav toolbar might need. Then it calls the refresh method of the button bar, which enables and disables buttons much like the txtbtns.navrefresh method. This code assumes that the standard vcr buttons are there, and also assumes that, if the form can edit data (based on a variable passed to it) there are "save", "new", and "restore" buttons. The individual buttons are not from classes, but they easily could be.

Given that Mr. Tai (or is it Mr. Shih? I'm not sure how that works) and I are stuck with wizard code to modify, and don't have a long time in which to do it, how 'bout this.... Take the methods of tsbaseform and make them methods of the buttonbar class. Make our buttonbar class be a container, not a toolbar. That way we can quickly rip out txtbtns from our forms and stick in the new class. Unlike Tastrade, we can make our individual buttons into classes. The two assumptions that the tstoolbar.refresh makes about what buttons are present are probably reasonable. I have never seen a set of vcr buttons that wasn't "top, prior, next, bottom", and I think all buttons for adding records should probably be "new, add, revert". If not, we can add a forest of IF... commands to the refresh, such as IF TYPE('THIS.cmdTop') # 'U' THIS.cmdTop.Enabled = 'T' or whatever. If you want to add the "Find" and "Print" buttons from txtbtns to your new button bar class, you can, but its refresh should definitely include an IF... to check whether they are really there. They are both pretty crude and you might want to get rid of them, if you don't have time to modify them.

Dang, I just wrote another book. Well, it's the core of our frameworks. Care to comment?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform