Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Methods in formset's forms' controls in a .prg
Message
 
To
25/07/1998 16:51:42
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00121398
Message ID:
00121446
Views:
16
I'm seeing a couple of possibilities here. Try not using formset but rather form. I have found it much easier to design a class visually and create custom properties and methods. You can then put in main, PUBLIC oSomeFormName = " ".
Then when you launch the form in .prg:

do form SomeFormName name oSomeFormName linked with whatever, whatever

This way you have access to any method or property by asking:

if type('oSomeFormName') = "O"
oSomeFormName.control.click()
m.var = allt(oSomeFormName.control2.value)
etc.

Also you can put oSomeFormName = " " in destroy so if the form is not open the data type of oSomeFormName will be "C" not "O".

You can also return values from the form much like a messagebox. See do form in help. You might want to also consider using the messagebox command. ie:

if messagebox("what?", nWinType, cWinText) = 6
do something
else
or not
endif
There is also a list of constants that can be used for messagebox params in
one of the foxpro include files I think located in the tastrade example.

HTH

Eric K.

>I have a formset class; initially it contains only a form1 and an ok/cancel cmdgroup. Now when I createobject() it, I add several objects to formset.form1 programmatically. So far so good - I can set the controls' properties as I like, but that's all. Can't do any method code for the controls. They either have to be subclassed right where they are, or I can save the formset into a .scx and add method code there. This roughly defeats the purpose of the whole thing, because the intention of this class was to be used for little dialogs, with just a couple of controls, like the kind one usually runs before reporting, asking for date range and such matters. Having the code right within the same .prg which later runs the report grossly reduces the number of files and other clutter.
>
>Now to the funny thing. I've opened the saved form in the form designer, and added few lines in one of control's method. Saved. Opened in class browser and took a look at the source code, copied it into a .prg and found no way to run it. It was something like this:
>
>Define Class someclass as formsetclass
>
> add object form1 as form
> add object form1.control1 as textbox
>
> procedure control1.click
> wait "you clicked, sir?" window nowait
> endproc
>enddefine
>
>It showed " procedure control1.click" as if belonged to formset, and not to formset.form1. It compiled anyway, but refused to run, stating that object reference is wrong. So I changed it to procedure form1.control1.click", but wasn't any better. Tried a couple of other things, but none worked.
>
>Does anyone know a way around this, or the thing is simply impossible. The only solution I've found so far is like this:
>
>
>Define Class someclass as formsetclass
>
> add object form1 as form
> add object form1.control1 as MYtextbox
>EndDefine
>
>Define Class mytextbox as textbox
> procedure click
> wait "you clicked, sir?" window nowait
> endproc
>enddefine
>
>...but it seems like an overkill, having to subclass every control which needs some method code.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform