473,605 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modal forms

Is this possible? I have 3 forms frmGrandparent, frmParent & frmChild. Can
frmGrandparent do a frmParent.ShowD ialog() and then (while frmParent is open)
do a frmChild.ShowDi alog(). At the end of the day frmChild should be the
topmost form and the focus should be on it.
--
L. A. Jones
Nov 7 '07 #1
8 5173
On 2007-11-06 18:36:02 -0800, Dave <Da**@discussio ns.microsoft.co msaid:
Is this possible? I have 3 forms frmGrandparent, frmParent & frmChild. Can
frmGrandparent do a frmParent.ShowD ialog() and then (while frmParent is open)
do a frmChild.ShowDi alog(). At the end of the day frmChild should be the
topmost form and the focus should be on it.
The dialogs don't care in which class the code that shows the dialog
is. So sure, you can write code in your "frmGrandparent " class that
shows the "fmrChild" dialog.

Pete

Nov 7 '07 #2
Not normally. ShowDialog is blocking, so frmGrandparent will be blocked
waiting for frmParent to close, so it can't call frmChild.ShowDi alog().

frmParent could call frmChild.ShowDi alog()...

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Dave" wrote:
Is this possible? I have 3 forms frmGrandparent, frmParent & frmChild. Can
frmGrandparent do a frmParent.ShowD ialog() and then (while frmParent is open)
do a frmChild.ShowDi alog(). At the end of the day frmChild should be the
topmost form and the focus should be on it.
--
L. A. Jones
Nov 7 '07 #3
I did that but I was still able to access frmParent and frmChild dialogs
simultaneously. Do I need to explicitly specify that frmParent is the parent
of frmChild?
--
L. A. Jones
"Peter Duniho" wrote:
On 2007-11-06 18:36:02 -0800, Dave <Da**@discussio ns.microsoft.co msaid:
Is this possible? I have 3 forms frmGrandparent, frmParent & frmChild. Can
frmGrandparent do a frmParent.ShowD ialog() and then (while frmParent is open)
do a frmChild.ShowDi alog(). At the end of the day frmChild should be the
topmost form and the focus should be on it.

The dialogs don't care in which class the code that shows the dialog
is. So sure, you can write code in your "frmGrandparent " class that
shows the "fmrChild" dialog.

Pete

Nov 7 '07 #4
Let me explain the situation in detail. frmGrandparent is my main form.
frmParent is one of several data entry forms. frmChild is a login form. When
the computer is idle for a period of time then frmChild (login form) should
be displayed and it should have focus. I did not want to go into all the
frmParent (data entry forms) to write code to open my frmChild (login form)
after a timeout. I wanted to do it from frmGranparent (main form). But it
seems to be impossible.
--
L. A. Jones
"Peter Ritchie [C# MVP]" wrote:
Not normally. ShowDialog is blocking, so frmGrandparent will be blocked
waiting for frmParent to close, so it can't call frmChild.ShowDi alog().

frmParent could call frmChild.ShowDi alog()...

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Dave" wrote:
Is this possible? I have 3 forms frmGrandparent, frmParent & frmChild. Can
frmGrandparent do a frmParent.ShowD ialog() and then (while frmParent is open)
do a frmChild.ShowDi alog(). At the end of the day frmChild should be the
topmost form and the focus should be on it.
--
L. A. Jones
Nov 7 '07 #5
On 2007-11-06 19:11:00 -0800, Dave <Da**@discussio ns.microsoft.co msaid:
I did that but I was still able to access frmParent and frmChild dialogs
simultaneously. Do I need to explicitly specify that frmParent is the parent
of frmChild?
Well, what happens when you do that?

Nov 7 '07 #6
On 2007-11-06 19:27:01 -0800, Dave <Da**@discussio ns.microsoft.co msaid:
Let me explain the situation in detail. frmGrandparent is my main form.
frmParent is one of several data entry forms. frmChild is a login form. When
the computer is idle for a period of time then frmChild (login form) should
be displayed and it should have focus. I did not want to go into all the
frmParent (data entry forms) to write code to open my frmChild (login form)
after a timeout. I wanted to do it from frmGranparent (main form). But it
seems to be impossible.
It's not impossible. It works fine. You don't have to do anything
special, and you don't even need to specify a parent when you show the
dialog.

If you are having trouble, it's because you're doing something _more_
than what is necessary and which is messing things up.

I just tested this myself to be sure, two different ways:

1) second dialog shown by a button on first dialog
2) second dialog shown when a timer created in the main form expires

In both cases, the most-recently shown dialog is the only one that
accepts input.

You should post a concise-but-complete sample of code that demonstrates
how _you're_ trying to do it, and which reliably fails to accomplish
what you want it to.

Pete

p.s. Here's the "interestin g" excerpt of the test code I wrote, the
custom portion of the main form class. It doesn't include any of the
Designer-generated code, nor the custom code in DialogA and DialogB
since the implementation of both of those forms isn't relevant (they
could be completely empty as far as this code cares).

The main form has a single button, to which is attached the
button1_Click method. That method starts a 2-second timer, and then
shows the first dialog. When the timer expires, the second dialog is
shown. Once the second dialog is shown, it alone accepts user input:
using System;

using System.Collecti ons.Generic;

using System.Componen tModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows. Forms;

namespace TestNestedDialo g

{

public partial class Form1 : Form

{

public Form1()

{

InitializeCompo nent();

}

private void button1_Click(o bject sender, EventArgs e)

{

DialogA dlga = new DialogA();

Timer timer = new Timer();

timer.Tick += HandleTick;

timer.Interval = 2000;

timer.Start();

dlga.ShowDialog ();

}

private void HandleTick(obje ct sender, EventArgs e)

{

DialogB dlgb = new DialogB();

Timer timer = (Timer)sender;

timer.Stop();

dlgb.ShowDialog ();

}

}

}

Nov 7 '07 #7
How are you testing for idle? If you're using a timer click on
frmGrandparent, you could simply call frmChild.ShowDi alog(). I don't know if
that would mean frmParent would be inaccessible until frmChild is closed--I
would imagine not.

You'll likely have to implement frmParent as non-modal and fake modality by
disabling the other forms...

I'm not sure what the point of doing this is though. Are you attempting to
introduce tighter security than the computer currently has configured? If
there is a need for security of this nature it is usually domain-wide;
meaning it's a domain policy. If it isn't a domain policy there isn't a need
for security of that nature, which means the added security to the
application is still operating in a lower-security environment. i.e. if
security of this nature is important, its important for the entire computer.

Also, users hate having to re-authenticate themselves when they've already
been authenticated. If there is a password-protected screensaver running
they'll have to authenticate themselves there then again in your application.

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Dave" wrote:
Let me explain the situation in detail. frmGrandparent is my main form.
frmParent is one of several data entry forms. frmChild is a login form. When
the computer is idle for a period of time then frmChild (login form) should
be displayed and it should have focus. I did not want to go into all the
frmParent (data entry forms) to write code to open my frmChild (login form)
after a timeout. I wanted to do it from frmGranparent (main form). But it
seems to be impossible.
--
L. A. Jones
"Peter Ritchie [C# MVP]" wrote:
Not normally. ShowDialog is blocking, so frmGrandparent will be blocked
waiting for frmParent to close, so it can't call frmChild.ShowDi alog().

frmParent could call frmChild.ShowDi alog()...

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Dave" wrote:
Is this possible? I have 3 forms frmGrandparent, frmParent & frmChild. Can
frmGrandparent do a frmParent.ShowD ialog() and then (while frmParent is open)
do a frmChild.ShowDi alog(). At the end of the day frmChild should be the
topmost form and the focus should be on it.
--
L. A. Jones
Nov 7 '07 #8
On 2007-11-06 20:01:00 -0800, Peter Ritchie [C# MVP]
<PR****@newsgro ups.nospamsaid:
How are you testing for idle? If you're using a timer click on
frmGrandparent, you could simply call frmChild.ShowDi alog(). I don't know if
that would mean frmParent would be inaccessible until frmChild is closed--I
would imagine not.
In the simple case (e.g. the test code I wrote to make sure I wasn't
misremembering things), the only form that accepts input is the one
most recently shown with ShowDialog().
You'll likely have to implement frmParent as non-modal and fake modality by
disabling the other forms...
Nope. Works fine, no need to do funny tricks.

I completely agree with your other comments about whether this feature
is really necessary. But my experience has been that people don't
usually want to hear that the UI they designed needs fixing, even when
it's true; they're already set on doing it a particular way.

There is also the very small possibility that this is the rare scenario
where such a UI makes sense. I have seen kiosk-style applications
where the developer doesn't want a Windows authentication presented,
ever, but they do want to manage _some_ sort of authentication. Until
Windows provides a complete kiosk management API, I think developers
are stuck doing this sort of thing.

But it's not true that Windows makes it difficult. It works just fine,
assuming one isn't doing something weird.

Pete

Nov 7 '07 #9

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

Similar topics

0
413
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. There is a reference to Unsafe Native Methods and Callback functions, but Interop Services are not used. What is going on ? The problem does not occur if the form is made modal. Any thoughts would be appreciated. The code appears below for a simple...
3
8142
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 the code is 100% managed. The exception is not thrown if the dialog was modal (opened with ShowDialog()) or if the selection is made from, say, a ListBox. I have included a simple example below. I am using C#.NET 2003, Standard Edition.
2
2552
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 bring up a modal dialog (MessageBox)
8
2718
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 thread to access the database and then displays a modal dialog which allows the user to cancel the task, if it is taking longer than they want, and shows them a display of how long the query has been running so far.
2
2637
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 form.setModal(1) before calling form.show(). All works as expected on Linux. The form is modal, not allowing the main window to received the focus. If I call the form from within itself, the topmost form is modal, and not of the previous forms will...
2
4496
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 boxes (please see associated source code below): 1) Win32 API with context ("btnWin32WithContext_Click") 2) .NET Framework with context ("btnFrameworkWithContext_Click") 3) Win32 API withOUT context ("btnWin32WithOUTContext_Click")
11
2350
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 realized that despite suggestions to use DHTML-based modal dialogs are very common? there is not a single fully functional reliable copyright-free cross-browser alternative to say MsgBox (VBScript) or showModalDialog (IE). This way such suggestions up to...
2
3494
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 =ShowMainMenu("item") in the On Action event where ShowMainMenu is a public function in frmMain, and "item" is a string mapping to a button click event. (error trapping omitted) Public Function ShowMainMenu(strItem As String) As Boolean
4
4544
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 an option. I also need to check the values in a spread control on the forms before I close/dispose them. I'm using VB 2005. Is there some way for me to do this?
1
3559
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 as modal while others are opened up as modeless on this main form. Whenever some error occurs in client server communication we show it in modal message box. Now I ran into a case: a modal form is opened up on the main form. And some error...
0
7934
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8424
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8415
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8286
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6742
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1537
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.