>Hi all,
>
>I tried to define some class in a header file and use them in another program, however, I've some problem..
>
>FormDefine.h
>
>define class oForm as form
> autocenter=.T.
> caption="Testing"
>
> procedure queryunload
> clear event
> endproc
>enddefine
>
>
>and in CallForm.prg
>
>#include FormDefine.h
>
>TestForm=createobject("oForm")
>TestForm.show
>read events
>
>
>Then I have error message: "Class definition oForm is not found."
>
>What did I do wrong? I'd really hate to have 2-3k lines in my program.. <g>
>Thank a lot!
Jimi,
Include puts content as is to the place it called (as if you pasted contents there). BUT only directives are recognized in a header file and commands are ignored. Thus it can't see the definition there.
If you use VFP6 then :
Put your class definitions in a separate file (it might be 'FormDefine.h' but better have the extension .prg). And call like this :
TestForm=NewObject("oForm","FormDefine.prg")
TestForm.show
read events
If VFP5 or 3 then :
if !'FORMDEFINE.PRG'$set('PROCEDURE')
set procedure to FormDefine additive
endif
TestForm=NewObject("oForm","FormDefine.prg")
TestForm.show
read events
If you keep group of classes in the same file then having extra 2-3 lines at startup places wouldn't harm you :)
Cetin