Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Releasing public variable
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00875746
Message ID:
00877298
Vues:
19
Steve,

You are going through way too much work. Kinda forget the concept of "source code" and mostly forget prg files when it comes to classes especially GUI classes. Although some people argue that they prefer using prg based classes. I prefer to use vcx and scx based classes and forms, it's much cleaner IMO.

create classlib steve && this creates a steve.vcx & steve.vct file
create class cTextbox of steve as textbox && creates a first level subclass of the VFP textbox, every other textbox you ever use should derive from this class.

In the class designer for cTextbox "fix" the bug that allows backspaces to run oout of the textbox and start wiping data in the textbox before it in the tab order, by putting this in the KeyPress method:
LPARAMETERS nKeyCode, nShiftAltCtrl

if ( ( m.nKeyCode = 127 ) and ( this.SelStart = 0 ) )
   * prevent backspace from leaving this field
   nodefault
endif
close the class designer now you have a usable class.

create form test1 && opens the form designer, creates test1.scx/sct

and you can now put instances of the cTextbox subclass on the form. You won't see any code in the KeyPress method on the textboxes on the form because they inherit that code from the class. You can add more code to the instance by rightclicking it and selecting code. But typically all you are going to be doing with a textbox is setting it's visual attributes like size & position and setting the ControlSource to bind it to the correct data.

If you click the ! button the form will just run, there is no code generation phase like there used to be in FP2.x.

You should create a cForm class as your lowest level form and derive all forms from this one form. You can put code in the Load() method to define the SET environment you want when you start working with private datasession forms.

The class designer and form designer are the same tool, it just depends on which entity you are working on, a form or a class of a classlib.

The class browser Viewcode feature is designed to give you a "source code view" of everything you've done in the designer (in the Code window and property sets via the property sheet), but generally it is not a runnable prg. It will not be runnable if there is any containership of objects deeper than the form itself.

>Once I define a class and save it as a prg file, then use the Rettig program to
>convert to a scx file, I can't revise the code for the class in the Class Browser??
>Unless I take the code from veiwcode.prg, modify it,and then have it converted back to a
>scx file?? Or, can I begin with "Create class" but then where does the code go, or where
>can I say whether it's an object and if so which kind? It sounds like basic elements -
>like a form and a textbox -- could be designed with form designer, then saved as classes.
>Then if needed get the code for each from the class browser as viewcode. But if I then
>need or want to revise the underlying class definition in code, I need to always get
>at it via viewcode.prg?
>
>I understand the rest of what you just explained and thanks so much,
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform