I am developed a custom class based on a container that worked properly when it was on a form but when I converted it to a class I have issues I can't resolve. I have only one installation of VFP and sometimes I wonder if it might be corrupt.
In order to avoid any corruption of the visual tools I have attempted to come up with a small .prg program that creates a form, defines a custom class in code, and puts an instance of the class on the form. ,The following code was written by Microsoft's CoPilot but the author has not been able to make it work! The problem seems to be that the definition code needs to reference the class before it is instantiated.
* Create a blank form loMyForm = CREATEOBJECT("Form")
MESSAGEBOX("Form created successfully")
* Create an instance of your spotpick1 class loSpotPick1 = CREATEOBJECT("spotpick1")
MESSAGEBOX("Class created successfully")
* Add the spotpick1 to the form loMyForm.AddObject("SpotPick1", loSpotPick1)
* Show the form loMyForm.Show()
RETURN
DEFINE CLASS spotpick1 AS container PROCEDURE Init * Add your custom logic here (e.g., create controls, set properties) THIS.AddControls() ENDPROC
PROCEDURE AddControls LOCAL oTextbox1, oTextbox2 oTextbox1 = CREATEOBJECT("TextBox") oTextbox2 = CREATEOBJECT("TextBox") oTextbox1.Value = "Hello from TextBox 1" oTextbox2.Value = "Hello from TextBox 2" THIS.AddObject("Textbox1", oTextbox1) && Errors here THIS.AddObject("Textbox2", oTextbox2) && Errors here ENDPROC ENDDEFINE
Thanks in advance for any help! Joe
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---