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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An object based on a form class Floats independently, why?

Status
Not open for further replies.

jbailey268

Programmer
May 25, 2005
51
US
I created an object based on a form (scx). And although I set it as "In Top Level form" - it isn't, when instantiated.
Of course it doesn't really float. It just behaves as it was an independent window.

The Main Top form (call it form1); in it's init event I have
IF ! ("MYFORMCLASS" $ SET("Classlib"))
SET CLASSLIB TO C:\Develop\Progs3\MYFORMCLASS.vcx ADDITIVE
ENDIF

loformINSIDE=CREATEOBJECT('rankout')
loformINSIDE.SHOW()

ALso tried it with NEWOBJECT - no difference.
**loformINSIDE=NEWOBJECT('rankout','MYFORMCLASS')

The main top form shows and then the object that is shown just acts completely, independently of the MAIN FORM1 window.
What my objective is: That it be "attached." Like an image (or any other object) placed on the form. When the form moves it moves, as if it was a part of it's skin.
I tried "Always on Top"...I tried a foray into form sets. Sorry, too complicated...
I removed title bar of the class, experimented with border styles.
It's probably something simple. If not I can't work with the class object as is. When a user moves the main form the bottom section will not move.. ech!. I'll have to go back to painting objects directly on the main form1. I thought employing forward thinking my making it a class.
Also I'm in Visual 8.0 and I have not put this into an app yet. Just started fooling around with the form.
 
Check the form Desktop property. if it is .t. the form can be moved everywhere :)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
At most "in top level form" will confine the child form to the area of the top level form, it's still an independant form and not part of the top level form as an image.

You might consider using a container instead, or a pageframe.

Bye, Olaf.
 
Thank you both for your time. Olaf you are right.
I realize now you can not embed a form inside a form in this manner, anymore than you can put a command button object inside another command button object.

Solution I used: I placed original objects from the form in a conatiner and saved the container to a class. Then it worked. A one page pageframe would work too.

Observation: Wouldn't it be cool if Foxpro would allow a form class to be instantiated in a form and "docked." Can not a page frame be placed inside another pageframe?

Thanks again.
 
JBailey,

Wouldn't it be cool if Foxpro would allow a form class to be instantiated in a form and "docked."

Well, you can do that by calling the form's Dock method, passing 4 as the parameter. Would that do what you want?

(This only applies to VFP 9.0 and above.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Yes Mike that sounds like it would do it. But I was in VFP 8.

Ironic that my wish list has already been granted in VFP9.
Yet another reason to step upward.

Thanks.
 
Hi jbailey,

always glad to be of help.

A docked form will give you a pageframe like group of tabs and might not really be, what you want. On the other side a container is an all purpose object you can put into a form, a pageframe or whatever containerlike control (there is also one very special: the 'control' control). So things you want to use in several places are best put into a container.

I'd say docking forms is for letting the user put together his favourites in one place as he likes, and wouldn't use it for composing forms as a developer. You might have a proposed/recommended set of docked forms, but if I don't want the user to be able to pull the forms apart, I'd do a pagerframe.

If talking about forms inside forms the way you might know them from elsewhere, the better idea would be a form behaving like a container inside another form, but it has some vfp specific issues: A form (at least an SCX form) can have a default or private datasession, and a form might be modal or modeless (modal forms would halt any other form or menu from being active) to name just two of several issues. This or that could be contradictive to the outer form. You might take it as a feature and the inner form might have it's own datasession and things like modal/modelss could be decided by the outmost form. Surely there are ways to define the behaviour as needed.

It's true that even in Access I believe you can use a form inside a form. It's a nice concept, as it goes beyond docking and allows easy integration without eg the problem to have form methods you'd need to transform to container methods or designing for reuse in the first place (Your design might be good, but for being flexible in any way you'd need to define all your forms as containers first and I think nobody does so).

In one way VFP knows forms inside forms: ActiveX controls are forms (and eg have a hwnd). But you can't create ActiveX controls with VFP. And even if, I'd prefer to do it natively.

On the positive side, if you design your reusable classes as containers you have a lightweight 'form' you can use inside any other container like control. As you already did transform a form to a container you know it's doable.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top