PDA

View Full Version : Next try - prg starts class as a form



Jens
2012-10-29, 11:10
In the next test I try to start the form from a class.

In the VFP-prg I do that this way:

SET CLASSLIB TO CLASSES\VFPTEST.VCX ADDITIVE
loForm = CREATEOBJECT("vfptest")
loForm.Show()
After the import I changed it to (vfptest_start.prg):

set default to C:\Lianja\apps\a-vfp-prg-vcx
SET CLASSLIB TO VFPTEST.VCP ADDITIVE
loForm = CREATEOBJECT("vfptest")
loForm.Show()
The VFPTEST.VCP has the following code:

vfptest = createobject("_3MR0Q03GH")
vfptest.addobject("Cip_button1", "_3MR0Q03GI")
** Make the form visible.
vfptest.show

define class _3MR0Q03GH as form
** Properties
DoCreate = .T.
Caption = "VFP-Test - Maske aus SCX"
WindowType = 1
Name = "Form1"
enddefine

define class _3MR0Q03GI as commandbutton
** Properties
Top = 216
Left = 288
Height = 27
Width = 84
Caption = "Be\<enden"
Name = "Cip_button1"

** Methods
PROCEDURE Click
THISFORM.Release()
ENDPROC
enddefine
When I start vfptest_start.prg nothing happens.
I wonder, why there is the createobject in the vcp file?

When I use the VFP-Class-Browser and use View-Class-Code I get the following:

DEFINE CLASS vfptest AS form
DoCreate = .T.
Caption = "VFP-Test - Maske aus VCX"
WindowType = 1
Name = "Form1"

ADD OBJECT cip_button1 AS commandbutton WITH ;
Top = 216, ;
Left = 288, ;
Height = 27, ;
Width = 84, ;
Caption = "Be\<enden", ;
Name = "Cip_button1"


PROCEDURE cip_button1.Click
THISFORM.Release()
ENDPROC
ENDDEFINE
I copyed that and pastet into the vcp and it works!

lianjasupport
2012-10-29, 11:19
The createobject is in the vcp file so that you can run it as a complete script/program if required. If you DO the vcp file, your form will run, or as you have done, you can modify the vcp and use SET CLASSLIB.

lianjasupport
2012-10-29, 11:26
Ah, it seems like the converter is incorrect for vcx, it should be defining a class called vfptest not an object. Please submit a ticket for that and we will get it fixed.

lazyfox
2012-10-29, 14:20
For utilizing more than 1 vcx/scx, you need to fix the logic for unique names -
works in the OOP version, not enough tested in the old version.
You received both versions via ticketing system.

Int he old code from 8 instantiating a form hinged on a form class in scx/vcx,
also other container classes get instantiating code - better design would be to add a specific
method encapsulating all addobject-calls which substitute the add object commands.

On the list but not implemented yet ;-)

lianjasupport
2012-10-29, 18:15
This has already been done in beta10.

barrymavin
2012-10-30, 02:15
This incorrect parsing of vcx files has now been fixed in Beta10.

There are still some issues that need looked at for scx files which contain controls/containers that are coming from an external vcx file. This has not yet been addressed and will not be in Beta10.

If you convert "normal" scx and vcx files it should now be ok but if the scx has controls/containers coming from an external vcx file it will not currently work.

Also (as an aside) this is why some pjx files don't import everything as the pjx file has no knowledge of the dependent vcx files as this information is contained in the scx file. A bit of a poor design to say the least.

lazyfox
2012-10-30, 03:30
There are still some issues that need looked at for scx files which contain controls/containers that are coming from an external vcx file. This has not yet been addressed and will not be in Beta10.
If you convert "normal" scx and vcx files it should now be ok but if the scx has controls/containers coming from an external vcx file it will not currently work.

Barry,

if you or Hank sets up the library/*.prg in LianjaX after 10, this issue will be adressed as soon as somebody runs into it.
Currently output as "define xxx as yyy of zzz_vcx.prg", for better testing if such a converted vcx would still work in vfp,
but other naming schema (vcp/scp) is just a method call in the OOP version and much better suited for others to enhance.

As I have only created a dummy version of inheritance/aggregation spanning multiple files a real application might be better.

barrymavin
2012-10-30, 03:47
Thomas, As I mentioned I have fixed the vcx issue already. I will look into the scx with dependent vcx files after beta10 as we are doing final QA on it at the moment and there is so much in it we need to get it out the door. After that we will look into this issue. It is not as straightforward as it may appear.