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

Bring Control To Front At Design Time

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
VFP 9 SP1. I have a shape (rectangle) on a form and a textbox and a combobox inside the shape. When I select the textbox and combobox and click oh the bring to front, I can click on either of these two with no problem. If I save and run the form and redit the form the shape is now in front of the other two controls so I cannot click on them to make changes to their properties. This doesn't happen all of the time. I've used zorder with some success, but this time it doesn't seem to solve the problem. Is there any easy solution to this? Do I need to add them in any special sequence.

Auguy
Sylvania/Toledo Ohio
 
One obvious alternative is to use a Container instead of a Shape. Then, the textbox and combobox would be actually contained by the Container, but always accessible. If you have code that addresses those objects, you'd have to modify it to include the extra level.

Tamar
 
The easiest solution would be to change Shape to Container and put the controls inside the container. Shapes cannot contain other controls so you're susceptible to Zorder madness.

Instead of "Bring to front" on your editable controls, try "Send to back" on the shape. It *should* be respected/remembered.

You mention both design time and run time, so it's a little difficult to see exactly where you're having problems. If you're messing with Zorder at runtime, it can be easy to inadvertently override changes made in the designer.
 
Bring To Frot / Send To Back should have a permanent effect, so I'm a bit stumped.

In VFP7 I once had to maintain a rather complex form with many pageframes that also just sometimes misbehaved and in that case the controls got a mess, containers shrinked and clipped controls in them. So I believe you have this behaviour, as I have seen worse.

I haven't had any problem like this in VFP9 anymore, but who knows, I very rarely use shapes.

You can USE yourform.scx and will find the controls in order from back to front.

Adding the shape first, then the controls, will result in that record order in the first place, so maybe it's a godd idea to redo these three form objects in that order, shape, then the textbox and combobox on it.

Bye, Olaf.
 
Thanks to all. I will change to containers to avoid this mess. I guess old habits are hard to break. By old I mean really old. I used to drive across town to pick up my updates when Fox was in Perrysburg Ohio.

Auguy
Sylvania/Toledo Ohio
 
Hm, as long as the rectangle shap merely is added for visual aiding the user to see a group of controls, the container is not a natural replacement. Editing the form with containers you will need CTRL+Click to first click into the container, then can put controls inside and later get hands on these controls.

But for sure containers solve the zorder problem. Also you need to change adressing the controls, eg if you now have code adressing the textbos as Thisform.Textbox1, in the future this would be Thisform.Container1.Textbox1. If you have generic code adressing all controls this needs to add recursing into containers. Nothing new really, as even without usin containers you have the same with controls on pages of pageframes or within grid columns, they even have more levels of a hierarchy. Nevertheless, this can mean changing quite a lot of code, just for solving that zorder problem, you can always fix with a send to back of the rectangle.

So why not first try as Dan also suggested: Simply Send To Back the rectangle and Save the form. That should stay that way, as it really changes the record order, and records of an SCX don't reorder in between edits. Just give it oe more try. Or do you use any hacks into scxes?

On the other side, if this is not just for decoration it can even pay to first make a class based on container, put the group of controls you need into it and reuse it on many forms. Not only pageframes and their pages, but also such containers can be subforms or miniforms, which can be reused repeatedly. From that perspective the container is even a good coice, if you don't make it visible to the user, make it's border width 0 and its backstyle transparent.

From the VFP7 experience with the mangled form I talked about, containers are the controls on it changing their size, clipping the controls inside. So if the containers misbehave, this is even messier than just the zorder problem.

Take all his into account, I can just say I do use containers for the simplest combination of a label plus a control, with code inside that class taking care of the label caption in the currently configured language. Such small lightweight classes can even pay to write code once and use many times.

Bye, Olaf.
 
Mike, I never met Dave Fulton, but I did talk with Chris Williams a few times and I am an acquaintance of Richard LaValley's son who lives in the area, but I haven't seen him in some time.

Olaf, thanks for the tips. I did the Send to Back many times without success. Sometimes it seems to work and other times it doesn't. In this case there wasn't too much code to change when referencing the controls inside of the container so that's what I did.


Auguy
Sylvania/Toledo Ohio
 
It sounds like you are adding the shape then adding the controls, which would add the controls to the shape rather than adding the controls to the form itself. Sort of like adding a container.
If that's the case, send to back or front sends the whole package to front or back and you will still have to CTRL+Click on the shape then click on any of the other added controls to set focus on them.
If you were to add the other controls to the form THEN add the shape, the send to back should keep its position.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Dave, you can't put controls inside a shape control, meaning as child objects. Shape class has no AddObject() method, which means it's also not possible to add IN to the shape in a designer.

You only visually put controls inside a rectangle, but both shape and controls are children of the form.

For some reason the shape came up from time to time, even if Auguy send it to back, and now the solution really is the container.

Bye, Olaf.
 
I got this problem with picture object. My solution, you can just make the shape very small. Then, in the init method, you change the width and height. That way, you can modify at design time, and it's perfect at run time.

 
Thanks FoxAll, I will try that trick the next time run into this problem.

Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top