>Since I appear to use Messagebox a lot instead of forms (for mere little warnings, like "Do you really want to delete this record" or "If you do this, I will do this"), I wonder if I should have a class base for my Messageboxes? I don't even know how to create a VFP class (other than just PROCEDURE in a main.prg), so that may be a good experience for me (as well I should do the same for ENABLED in the form's method). Is doing a Method the same as doing a VFP class or same idea?
A short "class" in designing classes:
Open the project manager.
Select "Classes".
Click on "New".
Class Name = "cSample".
Based on "Custom".
Store in "SampleClasses".
Click on "OK".
View | Code.
Make sure you select procedure "Init".
Type the following code:lparameters tcMessage
MessageBox(tcMessage)
return .F.
Save your changes.
set classlib to SampleClasses
createobject("cSample", "MyText")
Instead of using Init(), some programmers prefer to create the object, and call methods later. Create properties and methods through Class | New Property, and Class | New Method.
Instead of a non-visual class, you can also create a class based on Form. After creating the class, it is not initially visible. Sample solution (includes use of properties):loMessageBox = CreateObject("cMyMessageBoxForm")
loMessageBox.Caption = "My Error Message"
loMessageBox.Show()
If you base a class, say, on TextBox, you can place objects based on that class on your forms.
You can also create a class through code (HELP DEFINE CLASS), but the visual approach, outlined above, is simpler.
Regards, Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)