473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Modal Forms

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
Nov 21 '05 #1
3 2252
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

"Tim Marsden" wrote:
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

Nov 21 '05 #2
Thanks

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

Tim
"Nigel Armstrong" <Ni************@discussions.microsoft.com> wrote in
message news:08**********************************@microsof t.com...
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

"Tim Marsden" wrote:
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

Nov 21 '05 #3
What about disabling the form you don't want to be useable?

--

Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Building better tools for developers - Be part of it!


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hector | last post by:
I have a ComboBox set up in a non-modal form. When a selection is made from the ComboBox, the handler code closes the form, but then the system crashes because of an unhandled NullReferenceException....
3
by: Andrew | last post by:
I get a Null Reference Exception if I close a non-modal dialog (that is, a form opened with Show()) when a selection is made from a ComboBox. The error message refers to Unsafe Native Methods, but...
2
by: cassidyc | last post by:
Hi, I was wondering if anyone has come accross this issue? And if they have any solutions I have that can create new copies of itself Form1 as = new form1(); af.show(); This form can also...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
2
by: Mike | last post by:
Hi, I'm having a problem with modal forms on windows. I've written a very short test program, with a main window and a form called from the main window. The form is set to modal with...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have...
2
by: diogenes | last post by:
I have created many shortcut/popup (aka context, or right-click) menus for my application - instead of toolbars or standard drop-down menus. Within my custom menu, I am using...
4
by: =?Utf-8?B?Z2luYWNyZXNzZQ==?= | last post by:
I am trying to close/dispose multiple instances of a form but because they are modal and hidden, they do not show up in My.Application.OpenForms. They must be modal, so making them modeless is not...
1
by: Mohit | last post by:
Hi all, I am working on a windows based client server application with multiple forms. All forms are having custom title bars with no default bars. There is one main form. Some forms are opened up...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.