Hi all,
How can I convert sample prg with define class into visible form .scx file. When I put all prg code into command window, everything work fine, but I wish modify form in graphical environment ?
Milos
I agree with Mike Gagnon. You have to do this by hand.
Create a form in the form designer. Add the controls. Set the properties. Finally, copy and paste the method code from the PRG to the methods of the form.
I wish there was an easier way, but if there is, I have never heard of it.
SET DEFAULT TO GETDIR()
Ovse=NEWOBJECT("MyVse"
Ovse.SAVEASCLASS("MyVse", "MyVse" && write VCX
Ovse.saveas("MyVse" && write SCX,SCT
DEFINE CLASS MyVse AS form
ENDDEFINE
...work in VFP8? I tried it in VFP7 and it does not work, complaining about something having to do with a nonvisual element of the class. Please note the corrections to your posted code above, i figure you were just in a hurry.
Slighthaze = NULL craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon
SORRY to ALL,
My mistake.
SAVEASCLASS doesn't work. (something about visible and nonvisible forms). SAVEAS work in BOTH vfp7/8.
You can write VCX from form with
MODI FORM and then SAVE AS CLASS.
But here is another problem. I can't modify form. Any change I made come after save unchanged. How can I avoid a INHERIT in form properties. Sorry, I am beginer and a little confused.
I think that is a good start for me.
This code works fine:
SET DEFAULT TO GETDIR()
Ovse=NEWOBJECT("MyVse"
Ovse.SAVEAS("MyVse" && write SCX,SCT
Yes, that will create the SXC -- well done. But I don't think it will preserve any method code that you include in the DEFINE CLASS. Needs more experimenting.
Can you give me suggestion how to unlock form created with SAVEAS for modifications ? I put then methods by hand into form. It is a lot ready-made for me if I don't need to make GUI interface as new form.
program PrgToVcx but unfortunately with limitation:
• PROCEDURE and FUNCTION names must not reference an object hierarchy. I.e., PrgToVcx ignores constructions like PROCEDURE MyButton.Click.
SET DEFAULT TO GETDIR()
Ovse=NEWOBJECT("MyVse"
Ovse.SAVEAS("MyVse" && write SCX,SCT
I use modi form and then save it, but!?
I can't modify form. Any change I made come after save and reopen form unchanged. How can I avoid a INHERIT in form properties.
All procedures is still in prg file, all my changes on form go away. In my properies window Load Event have value (INHERIT MyPrg.prg) and propertie ClassLibrary (MyPrg.fxp)
That's not the behaviour I am seeing. I ran your code, created the SCX, and modified the properties without any difficulty.
However, when I added some method code in the DEFINE CLASS, I could not see it in the SCX. It appears that the code is still in the parent class, but of course there is no way of accessing that. I think that is what you are seeing as well.
I don't know what the solution is. Maybe you need a different approach to the whole problem.
Mike,
Sorry,
When I MODI FORM MyForm /everythink is OK!!
I save the form, but when I open form (reopen) again it is unchanged.
My explicite sample! (from *++++ to *++++)
*+++
Public oForm
oForm = Createobject('myForm')
****** HIRE I add line SAVEAS("MyForm"
oForm.Show
Define Class myForm As Form
DataSession = 2
Width = 800
Height = 400
BorderStyle=2
AutoCenter=.T.
DoCreate = .T.
Caption = "Customer Orders"
Name = "frmCusOrders"
Add Object lblCustomerID As Label With ;
Caption = "Customer ID", ;
Left = 15, Top = 10, Width = 60, Alignment = 1
Add Object txtCustomerID As TextBox With ;
ControlSource = "customer.cust_id", ;
Left = 80, Top = 6, Width = 58
Add Object lblCompany As Label With ;
Caption = "Company", ;
Left = 15, Top = 34, Width = 60, Alignment = 1
Add Object txtCompany As TextBox With ;
ControlSource = "customer.company", ;
Left = 80, Top = 30, Width = 290
Add Object lblContact As Label With ;
Caption = "Contact", ;
Left = 15, Top = 58, Width = 60, Alignment = 1
Add Object txtContact As TextBox With ;
ControlSource = "customer.contact", ;
Left = 80, Top = 54, Width = 220
Add Object lblTitle As Label With ;
Caption = "Title", ;
Left = 15, Top = 82, Width = 60, Alignment = 1
Add Object txtTitle As TextBox With ;
ControlSource = "customer.title", ;
Left = 80, Top = 78, Width = 220
Procedure cmdSimpleNav.Click
Local loObj
loObj = Sys(1270)
If !(Type('loObj.Parent') = 'O' And Compobj(loObj.Parent,This))
Return
Endif
With This
Select (.TableNav)
Do Case
Case This.Value = 1
Locate
Case This.Value = 2
Skip -1
If Bof()
Locate
Endif
Case This.Value = 3
Skip
If Eof()
Go Bottom
Endif
Case This.Value = 4
Go Bottom
Endcase
.EnabDisabButtons()
Endwith
Thisform.Refresh
Endproc
Procedure cmdSimpleNav.EnabDisabButtons
Local lnCurrent
With This
Select (.TableNav)
lnCurrent = Recno()
Skip -1
Store !Bof() To .Buttons(1).Enabled,.Buttons(2).Enabled
Go lnCurrent
Skip
Store !Eof() To .Buttons(3).Enabled,.Buttons(4).Enabled
.Refresh
Endwith
Go lnCurrent
Endproc
Procedure Load && Prepare data here
Set Talk Off
Set Deleted On
Set Century On
Set Multilocks On
Set Exclusive Off && Other sets you need
Use (_samples+'data\customer')
Use (_samples+'data\orders') In 0
CursorSetProp("Buffering",5,"Customer"
CursorSetProp("Buffering",5,"Orders"
Endproc
I cut this sample code from this forum and paste into VFP8 command window.I select all the code and run!FINE. Then I save code to MyPrg.prg and modify [I append statement SAVEAS("My_form"]. If I MODIFY FORM My_form, all my changes is immutable.
What is your suggestion.
I think, I squander your time.
Milos
Sorry, did you try my written code in ???.prg !!!???
I still assure my (cut .and. paste code)! My code works good, but you say that you can MODI FORM and save without tribulation??
I don't!
Mike, don't forget, I am BEGIN veracious VFP programer,[help me - why not?!]
What is your suggestion?
I think, I squander your time[a(lott)].
Please. give me a STEP by STEP sample, becouse I am a little confuse.
Mike, DSummZZZ and ALL ,
I always spend a lot of time before ask somethings!!!?
Did you try bescribe code and than suggest ME.
I think, I must learn VFP from underground begin.
I've tried running your code, but SAVEAS() don't work. I'm running VFP 7 though, not VFP 8.
But, that form is not that complex. Recreate it from scratch if you can't get this stuff to work. There aren't that many objects on it and cut-and-pasting the method code won't take that much.
Yes, I have been running your code throughout this thread.
Don't worry about wasting our time. The forum is for people who are able to spend time helping others.
However, you should keep in mind that the technique that you are trying to develop is very unusual. I have never seen this technique used before, and it could be that you are stretching Visual Foxpro. That's not a bad thing, but I always feel that when things get too complicated and unusual, it maybe time to look for a simpler solution.
If you are just trying to convert one or two simple forms, it might be easier to start them again in the form designer, as Dave suggested. If you have many forms to convert, I would suggest that you re-consider the need to convert them. It's true that it is easier to work with forms and classes using the visual design tools, but it is not that difficult to work with PRG files as well.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.