Modeless form with parent form

G

Guest

Hello,

I am trying to create a modeless form whose parent is another form. If the
modeless form is toplevel it won't let me set the parent, if the modeless
form is not toplevel it won't let me show. I 'solved' the problem by making
the modeless form toplevel only after it is shown. This seems to work but I
wonder if there is a better way.
Another choice is to use the Win32 API to force the modeless form to be a
child of the other form.

Thanks,

Jeff
 
G

Guest

Hi Jeff,

Are you sure you want to set the "parent" of the popup-form? Then you
cannot set the toplevel-property of the "child"-form to true (exception:
Cannot change top-level style of a parented control).

Usually, you want to set the owner of a popup-form, not the parent. That
way you prevent the popup-form from disappearing behind the owner form, and
is the owner form is closed, the owned form is closed as well.

Hope this helps,

Joris
 
G

Guest

Hello Joris,

My popup form has to be modeless, i.e. still allow user to click on parent
form when popup form is shown. If I don't set the parent of the popup form I
can alt-tab and see just my dialog on top of another window.

I think it may be worthwhile to be owned as well for the auto closing.

Thanks,

Jeff
 
G

Guest

Have you tried it, setting the owner? If you alt-tab, or click on another
window then both the forms are hidden behind the new window in the front, or
both windows are shown in front of the other windows. You cannot have the
owner form hidden behind, and the popup form shown in front of another
application.

Joris
 
G

Guest

Actually my initial code was dlg.Show(this) which sets the owner. When I did
this I saw two entries in the task bar (and two entries when alt-tab). I
have now fixed this by setting the ShowInTaskBar to false.
Now my issue is that I need to restrict the dialog location to the client
area of the owner. When I force the modeless dialog to have the owner form
as parent it has the correct behavior.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top