Dave,

I've tried what you suggested but VFP is not finding the class I define.  
I suspect my problem is with setting the path as I don't fully understand 
your example.  At this point I set the path to the full path of the 
classes.prg file.

I'm pretty sure you are doing something tricky with a return as the first 
line in the Classes file.  Since I don't understand the trick I tried it 
both ways with the same results.

Here is the contents of the classes.prg file: - maybe there is something 
else I am missing:
RETURN
DEFINE CLASS WSbox as TextBox
  FUNCTION valid
    RETURN .f.
  ENDFUNC
ENDDEFINE   

Here is the line from the form that fails with  "Class definition WSbox 
is not found.":
 thisform.AddObject('TBTmCalc', 'WSbox')

Thanks - Joe

On Monday, December 22, 2008  9:30 AM, Dave Crozier wrote:
>
>Date: Mon, 22 Dec 2008 14:30:35 -0000
>From: Dave Crozier
>To: [email protected]
>cc:
>Subject: RE: Newbee - working with a programmatically created text box
>
>Joe,
>Put all your class code into a separate .prg file eg
>\Classes\VFP_Classes.prg.
>Make sure the path to this file is in the VFP path eg set path to .\Classes\
>
>In the VFP_Classes.prg make the first statement a return:
>
>* VFP_Classes.prg
>
>Return
>
>Define class clsMyTextBox as Textbox
>       ...
>Enddefine
>
>Define class clsMyGrid as Grid
>...
>Enddefine
>
>...etc etc
>
>In your initialization program you can then simply "do VFP_Classes". From
>then on you can create classes/objects using CreateObject() etc. whenever
>you want.
>
>This is not the only way to do it as you can create classes in many other
>ways for example from Visual class libraries etc. but it is the easiest way
>when you are starting out.
>
>Dave Crozier
>
>
>-----Original Message-----
>From: [email protected] [mailto:[email protected]] On Behalf
>Of Joe Yoder
>Sent: 22 December 2008 14:16
>To: [email protected]
>Subject: Re: Newbee - working with a programmatically created text box
>
>Further question - I tried the code you suggested immediately before the
>addobject in the procedure that adds the text box.  VFP tells me that I
>have broken the rules with a "Statement is not a procedure" compiler
>error message.  Where do I put the class definition code?  Does it need
>to be a part of a library for all time or can it be limited to a project
>until I really understand what I am doing?  Thanks - Joe
>
>On Monday, December 22, 2008  7:37 AM, Joe Yoder wrote:
>>
>>Date: Mon, 22 Dec 2008 07:37:54 -0500
>>From: Joe Yoder
>>To: [email protected]
>>cc:
>>Subject: Re: Newbee - working with a programmatically created text box
>>
>>Thanks for the answer.  I have never fully understood the process off
>>defining my own classes.  I thought in this case I could simply use an
>>existing class but could not figure out how to set the Valid function.
>>Do I understand correctly that the only way to control such functions is
>>to define my own class?  Thanks - Joe
>>
>>On Sunday, December 21, 2008 11:33 PM, MB Software Solutions General
>>Account wrote:
>>>
>>>Date: Sun, 21 Dec 2008 23:33:02 -0500 (EST)
>>>From: MB Software Solutions General Account
>>>To: [email protected]
>>>cc:
>>>Subject: Re: Newbee - working with a programmatically created text box
>>>
>>>Joe Yoder wrote:
>>>> I like the approach used by QuickBooks where pressing a mathematical
>>>operator in a numeric field brings up a mini worksheet where one can do
>>>math on the value in the field.  I'm working a similar implementation
>>>for time entry.
>>>>
>>>> A text box overlays a field used for time entry when a plus or minus
>>>operator is pressed in that field.  The text box expands to display a
>>>separate line for each value added or subtracted from the original value
>>>and serves as a mini worksheet.  When the entry is complete and the user
>>>presses the "Enter" key,  The text box is eliminated and the result of
>>>the math on the worksheet is entered in the original text field.
>>>>
>>>> I need to force all entry into the worksheet until it is complete so
>>>that program can finish the calculation and close the worksheet.  I
>>>think setting the valid as always false until an "Enter" is pressed will
>>>give the desired result.
>>>>
>>>> Can someone enlighten me about how to set the Valid function on a
>>>programmatically created text box?  Suggest a better approach?
>>>>
>>>
>>>
>>>Hi Joe,
>>>
>>>If you're "stickbuilding it" by creating it in a PRG, just define the
>>>Valid event of your class.
>>>
>>>DEFINE CLASS cboSample as Combobox
>>>
>>>     FUNCTION Valid
>>>     * This code runs just like it would if you set the code inside a VCX
>object
>>>     ENDFUNC
>>>
>>>ENDDEF
>>>
>>>
>>>
>>>
>>>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to