473,698 Members | 2,339 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can a parent form tell if it has a child form?

Hello all,

We have a main form. We have the message loop programmed to listen for 'key
strokes' from a bar code scanner.
But when the message loop 'hears' the keystrokes, we need to know if the
main form has a child window (specifically a modal child window).

Any ideas how we ask a form if it has any child windows? We've looked into
TopMost and TopLevel, but neither of those are what we are looking for.

Thanks in advance for your reply.

--
Allan Michaels
Ann Arbor, MI
May 21 '07 #1
4 1599
* Allan Michaels wrote, On 21-5-2007 21:05:
Hello all,

We have a main form. We have the message loop programmed to listen for 'key
strokes' from a bar code scanner.
But when the message loop 'hears' the keystrokes, we need to know if the
main form has a child window (specifically a modal child window).

Any ideas how we ask a form if it has any child windows? We've looked into
TopMost and TopLevel, but neither of those are what we are looking for.

Thanks in advance for your reply.
The best way to do this is to set a flag when a modal window is opened
and reset it when it closes from within the main form itself.

So something like:

bool showingModal = true;
using (ModalWindow mw = new ModalWindow())
{
mw.Closed += this.ResetModel ;
ModalWindow.Sho wDialog(this))
// get stuff if needed
}

Jesse
May 21 '07 #2
Thanks for the idea. However, due to the nature of the program that won't
work.
The main form has 10 tab pages, each one could bring up many different
windows. That doesn't include all the menu items that bring up windows.

Any other ideas? Thanks again for your reply.

--
Allan Michaels
Ann Arbor, MI
"Jesse Houwing" wrote:
* Allan Michaels wrote, On 21-5-2007 21:05:
Hello all,

We have a main form. We have the message loop programmed to listen for 'key
strokes' from a bar code scanner.
But when the message loop 'hears' the keystrokes, we need to know if the
main form has a child window (specifically a modal child window).

Any ideas how we ask a form if it has any child windows? We've looked into
TopMost and TopLevel, but neither of those are what we are looking for.

Thanks in advance for your reply.

The best way to do this is to set a flag when a modal window is opened
and reset it when it closes from within the main form itself.

So something like:

bool showingModal = true;
using (ModalWindow mw = new ModalWindow())
{
mw.Closed += this.ResetModel ;
ModalWindow.Sho wDialog(this))
// get stuff if needed
}

Jesse
May 21 '07 #3
Hi Allan,

I suggest that you set up an owner relationship between the main form and
other 'child' forms. You could get all the owned forms through the
OwnedForms collection of the main form.

The following is a sample.
public partial class Form1 : Form
{
private void Form1_Load(obje ct sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show(this) ;
Form3 frm3 = new Form3();
frm3.ShowDialog (this);
}

public void GetOwnedForms()
{
for (int i = 0; i < this.OwnedForms .Length; i++)
{
Console.WriteLi ne(this.OwnedFo rms[i].Name);
}
}
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

May 22 '07 #4
Thank you for your help Linda. Your post answers my questions.

--
Allan Michaels
Ann Arbor, MI

May 23 '07 #5

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

Similar topics

25
6200
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I rarely refer to a subform ir parent form's controls or records from the other form. Instead, I call a procedure in that form that does the job. That's all fine and good, and nothing at all revolutionary, but it leaves one with an annoying...
13
7406
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
1
3365
by: tdmailbox | last post by:
Is there a vb command that can tell me if I have focus in the child or parent form? Basicly I have a search macro that needs me to have focus to any field in the parent form. If my focus is set on any field in the parent form it will search that field. However if I have focus set to a field in the child form it fails. What I want to do is set focus to field1 of the parent table but ONLY if focus is on a field in the child form. Is...
37
2071
by: Geoff Jones | last post by:
Hi Suppose I have two forms: Form1 and Form2. I create and show an instance of Form2 in the code of Form1 e.g. Dim myForm2 = New Form2 myForm2.Show() How do I tell myForm2 that Form1 is its parent? That is, when I look at either "Parent" or "ParentForm" in Form2, they both show "Nothing".
4
3632
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if possible.. for example..i hav a menu in the parent form named "Administrator" whic has an item "mnuLogIn"..now when i click on login..another child form named "frmLogIn" is displayed..what i want to happen is this: when login form(frmLogIn) is...
2
2441
by: Matt | last post by:
Ok here is my problem: I have a MDI parent form called "Main" that I declare in a public module when I start up my program. This form holds the drop down menu that allows my users to access all of the child forms. Now lets say I have a child form called "Child." When I open up that child form from "Main" I shut off the menu on "Main" so that the user cannot open up any other forms while they are in the "Child" form.
4
3560
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
3
2742
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a speciality XML file editor, used to create and edit a special XML file. It is an MDI app since I want users to be able to have multiple XML files open at the same time. The parent form has the usual Menu bar with a File menu that has the
4
6053
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase this is all very difficult to explain in words, please bear with me as I endevour to explain what it is I am trying to do. It would be helpful if I could attach a graphics file to this posting that would help explain what it is I'm trying to achieve...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9027
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
8895
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
7725
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
6518
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
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.