Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using .PRG Classes
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00442305
Message ID:
00443037
Vues:
65
I was cruising through this thread. Having just worked a case using a PRG class library (even an OCX control).
ITIS: SET PROCEDURE TO PRG1,PRG2
several class definitions may go into a PRG. They seem to be referenced by the DEFINE 'name' at addobject()
so a procedure file was needed:
*MyClassProc.prg && Top of class definitions
define class tbc as Container
*..left,height,top,etc
SpecialEffect=0
enddef

define class c_tb as Olecontrol && This is an OCX
procedure ButtonClick(Button)
=messagebox(button.key)
endproc
enddef
* End of MyClassProc.PRG

Then, in MyForm Init()
SET PROCEDURE TO MyClassProc
thisform.AddObject('tc','tbc') && The container
with thisform.tc
.width=thisform.width
.visible=.t.
endwith

* Added the OCX Tool bar to the container
thisform.tc.addobject('tb','c_tb','MSComctlLib.Toolbar.2') && Suprise! this worked.
with thisform.tc.tb
.width=30
.buttonheight=20
.buttonwidth=20
.buttons.add(,[EXCEL],,0,)
.buttons.add(,,,3,)
.visible=.t.
endwith

The MSComctlLib.Toolbar.2 ButtonClick fines from inside the define in MyClassProc.prg. What is really interesting is the AddObject() method may be used. Not being restricted to CREATEOBJECT() to instanciate from a PRG DEFINE was the big lesson.

>>>Now how can I get the second class to know that the parent class Abc exists?
>>
>>I see you've gotten the SET PROC answer, but just for your information, VFP7 has a new clause for DEFINE CLASS:
>>
>>DEFINE CLASS ClassName1 AS ParentClass [OF ClassLibrary] [OLEPUBLIC]
>>
>>which will be able to do what you want. For now, the class has to be avialable when you run the thing, either with SET PROC or SET CLASSLIB
>
>Cool. Glad to hear that you can specify the class library in VFP 7.0. I'd still like to know if there is a solution for VFP 6 if anyone knows of one.
Imagination is more important than knowledge
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform