Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encapsulating forms (?) 2

Status
Not open for further replies.

florindaniel

Programmer
Dec 4, 2009
120
RO
Hello,

I have this three object I use often and in a similar way:
a label explaining the type of info, a textbox to key in the data and a command button to search for that data in a table. I tried to encapsulate them and define a class
so I can use them easy. I don't know how to handle this: in the click event of the button I need to use a form where I show (in a grid) the table and from where I choose a value.
If I say something like: DO FORM SelData... it doesn't work.
Is there a way to encapsulate that form or is just a silly idea and there's some other way to handle that?

Thank you
Daniel
 
The way I usually handle this kind of requirement is to add a custom property to the container to hold the name of the form to run. Then the code is something like:

IF NOT EMPTY(This.cFormToRun)
DO FORM (This.cFormToRun)
ENDIF

That said, your direct call should work. What's wrong?

Tamar
 
First of all I assume you put a label, textbox and button in a container class to have a composed single class to reuse, Technically encapsulating a form within that container is not possible and you wouldn't do that anyway.

If you really want to go OOP you perhaps should rather not DO FORM, but instnaciate a form class, but still like Tamar says DO FORM would work from within such a compound class as from a single button on some form. What's wrong?

Bye, Olaf.
 
Thank you very much,

Nothing is wrong (now) if I use that custom property.

I'm not very clear if I have to make a copy of the form for each application I make (actually I can manage the programming part -at some level...-, but organizing folders, include or not OCX in projects, declaring paths, where the components are,etc... - that's a problem for me -)

I indeed have a container class with those three controls.
However, I tried the other way (OOP) and I've made a special class containing the form + controls. In the click event of the button :
loSelForm = NEWOBJECT('MySelDate','libs\MyLib')
but I don't know how to use it (!).
Do Form (loSelForm.Name) With ... doesn't work.

Thank you again
Daniel
 
loSelForm now is the form, you need to set it visible in the next step, loSelForm.Show(), not DO FORM, you can only DO FORM an scx, not a form already being run...

You should perhaps take your time to learn a bit of basics, OOP can't be learned by try and error.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top