Modal Forms

T

Tim Marsden

Hi,

I have a menu form.
The user selects an item from then menu and it shows the maintenance form
for the item.
This maintenance form is modeless so the user can select another item to
edit from then menu at the same time.
However from the maintenance from the user can edit properties, this shows a
dialog box to edit the value, this form is modal.
I want to force the user to close the property dialog before selecting
anything else on that item maintenance form, but not block the user from
using the other maintenance form.
But if the property dialog is modal it stops the user using any other part
of the app.

Any suggestions on how the modal form can only affect its parent, but allow
other forms in the app to be selected.

Tim
 
G

Guest

Hi Tim

I haven't tried this with sample code, so I don't know if it will work in
your situation - but it's worth a go anyway. If you set the Owner property
of the 'dialog', then you will get a floating window - it will not be modal -
but you could then respond to getting focus in the owning form to check the
OwnedForms property, and switch focus back to the owned form if it is not
nothing...

Perhaps the description is harder than the code you will write!

When you show the form, instead of ShowDialog():

newForm.Owner = Me
newForm.Show()

In the OnGotFocus override:

If Not Me.OwnedForms(0) Is Nothing Then Me.OwnedForms(0).Focus()

You'll also need to set the Owner to Nothing in the OnClosed override in the
'dialog' form so that you avoid object disposed related exceptions.

HTH

Nigel Armstrong
 
T

Tim Marsden

Thanks

I will try.
I have also tried threading to start the maintenance forms on a new thread.

Tim
 

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