Re: CenterParent Question

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Mon, 16 Jul 2007 01:29:34 -0700, > Adrian < <x@xxxxx> wrote:

[...]
Calculating where Form2 should go and setting its position accordingly is
not such a demanding task. However, it would be rather convenient if you
could just define what the parent is and direct the child form to go in the middle.

As far as I know, you can do this. But you do have to declare one form to be the parent of another.

If MS provides that option, it would not be unreasonable to expect
it to work without side-effects.

But the enumeration value you're trying to use is called "CenterToParent", not "CenterToArbitraryForm". The "Parent" form has a very particular relationship to the child form. It is normally applicable, for example, to MDI child forms and dialog boxes. One should expect to be able to take advantage of "CenterToParent" in those situations, and not in other situations.

If you create a parent-child relationship outside of situations like that, for the sole purpose of using CenterToParent, then you are inheriting all of the other behavior that a parent-child relationship implies.

All that said, I am not aware of anything terrible that might happen if you make one modeless top-level form the child of another. So, you might just try doing as I suggested, do some testing with different user scenarios to see how things like control focus, z-order, and window activation are affected, if at all.

I'm just pointing out that you wouldn't want to just blindly create a parent-child relationship without considering the consequences.

Presumably it will work ok if used in the
proper way - which I was attempting to discover.

Define "proper". The enumeration value is fairly self-documenting, in that it clearly is to be used when there is a parent-child relationship. That would be the "proper" way to use it. If you naturally have such a relationship, then the value is immediately useful. If you attempt to turn your situation into one with which that value can be used, then you have to accept whatever other behaviors come along with changing your situation into one that it otherwise fundamentally is not. Behaviors that presumably would be desirable when using MDI forms or a dialog box, but may or may not be an issue in other situations.

I reiterate: I do not have any specific knowledge of negative consequences of creating a parent-child relationship where none naturally exists. I am simply pointing out that you should not assume none exist.

Pete
.