Joe,
I've been a bit of a "Dick Head" here for the sake of saving time. Sorry,
but I forgot to say that you need to put the VFP_Classes file into the "Set
Procedure to ..." i.e
Assuming that the folder structure of your project is as follows:
+VFP_Project
--Data
--Programs
Init.prg
Subroutines.prg
....
--Forms
Form1.scx
....
--Menus
--Classes
VFP_Classes.prg
Assuming the VFP_Classes.prg is in the subfolder Classes of the main project
then your initialization program - I usually call it init.prg would be as
follows:
***************
* Init.prg
* This program sets up the defaults for the Program
*
Set talk off
Set echo off
* Set the home folder to be the location of the project
Set default to Application.ActiveProject.HomeDir
Set path to Data; Classes; Programs; Forms; Menus
Set procedure to Subroutines,VFP_Classes
Do VFP_Classes
Return
Return
*
* END OF PROGRAM
***************
************
* VFP_Classes.Prg
Return
Define class clsMyTextBox as TextBox
BackColor=rgb(255,0,0)
EndDefine
*
* End of Program
*************
Now you can use the:
...AddProperty("txtText","clsMyTextBox")
...CreateObject("txtText", "clsMyTextBox")
Or NewObject() as rewuired.
Remember that when you create an object it is initially set to be invisible,
so you need to set the Visible property to .T. after the instantiation or in
the object Init()if you want to see it!!!
Sorry about that slight slip up but I hold all this in my framework and
going back to basics again made me forget the "set Proc to" command.
Now to thrash myself within an inch of my life for such a stupid error!!!
Dave Crozier
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Joe Yoder
Sent: 22 December 2008 16:15
To: [email protected]
Subject: RE: Newbee - working with a programmatically created text box
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/6243418561174b43a3737f2d0d47a...@develop
** 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.