473,396 Members | 1,785 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,396 software developers and data experts.

Child Window Interaction

Hi,

My MDI (Parentform) form can have 2 two type of forms (Datagridform and
graphicform). When users create a new form, they have to pick either child
form. When those child forms are created and user move the mouse over on one
of the child form, I want the rest of the childs form know about it. For
example, when the cursor is moving on a graphicform, I want the rest of the
graphic forms know the location of the mouse. The forms that are
datagridform should ignore this kind of information.

How can that be achieved?

Thanks,
Anthony
Oct 12 '07 #1
6 1928
ATT wrote:
My MDI (Parentform) form can have 2 two type of forms (Datagridform and
graphicform). When users create a new form, they have to pick either child
form. When those child forms are created and user move the mouse over on one
of the child form, I want the rest of the childs form know about it. For
example, when the cursor is moving on a graphicform, I want the rest of the
graphic forms know the location of the mouse. The forms that are
datagridform should ignore this kind of information.

How can that be achieved?
One way that comes to mind would be to have a static event in each child
form's class. In the constructor for each child form, that instance
would subscribe itself to the event. The child form would also handle
the appropriate events (I think you'd probably want the
Control.MouseEnter and Control.MouseLeave events, but I'm guessing since
you're asking the question you already have an idea of how you actually
want to detect the mouse movements), and upon detecting the mouse moving
over itself, raise the static event so that all of the other instances
of the same class know about it.

Pete
Oct 12 '07 #2
Pete,

Thanks for the suggestion. I have an override on OnMouseMove on the child
form. This is how I capture there is some movement on my application. You
mention "raise the static event so that all of the other instances of the
same class know about it." The question is how? I am new in Window
programming. Can you provide more detail on how to raise the event?

Thanks,
Anthony.

"Peter Duniho" wrote:
ATT wrote:
My MDI (Parentform) form can have 2 two type of forms (Datagridform and
graphicform). When users create a new form, they have to pick either child
form. When those child forms are created and user move the mouse over on one
of the child form, I want the rest of the childs form know about it. For
example, when the cursor is moving on a graphicform, I want the rest of the
graphic forms know the location of the mouse. The forms that are
datagridform should ignore this kind of information.

How can that be achieved?

One way that comes to mind would be to have a static event in each child
form's class. In the constructor for each child form, that instance
would subscribe itself to the event. The child form would also handle
the appropriate events (I think you'd probably want the
Control.MouseEnter and Control.MouseLeave events, but I'm guessing since
you're asking the question you already have an idea of how you actually
want to detect the mouse movements), and upon detecting the mouse moving
over itself, raise the static event so that all of the other instances
of the same class know about it.

Pete
Oct 12 '07 #3
ATT wrote:
Thanks for the suggestion. I have an override on OnMouseMove on the child
form. This is how I capture there is some movement on my application. You
mention "raise the static event so that all of the other instances of the
same class know about it." The question is how? I am new in Window
programming. Can you provide more detail on how to raise the event?
You may find this helpful:

http://msdn2.microsoft.com/en-us/lib...39(VS.71).aspx
Oct 12 '07 #4
Peter,

Thanks again to the pointer. I read more on events and delegates and come
with this code:

namespace test
{
public class mouseEvent : EventArgs
{
public string message = null;
public EventArgs e = null;
}
public class eventHandling
{
public event EventHandler Changed;

public void onChanged(mouseEvent e)
{
if (Changed != null)
Changed(this, e);
}
}
}

namespace test
{
public partial class Form1 : Form
{
private eventHandling eventhandle = new eventHandling();
public Form1()
{
InitializeComponent();
eventhandle.Changed += new EventHandler(MouseMoveHandler);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
string message = "x: " + e.X.ToString() + " y: " + e.Y.ToString();
mouseEvent parm = new mouseEvent();
parm.e = e;
parm.message = message;
eventhandle.onChanged(parm);
}
private void MouseMoveHandler(object sender, EventArgs e)
{
mouseEvent parm = (mouseEvent)e;
label1.Text = parm.message;
}
}
}

The second section of the code is on the child form. When doing the test, I
can see my text updated with the current position of the cursor. But it does
not update the text on other child forms. The text is updated only for its
own window. How can I make all the child form see the same message?

Thanks in advance,
Anthony.

"Peter Duniho" wrote:
ATT wrote:
Thanks for the suggestion. I have an override on OnMouseMove on the child
form. This is how I capture there is some movement on my application. You
mention "raise the static event so that all of the other instances of the
same class know about it." The question is how? I am new in Window
programming. Can you provide more detail on how to raise the event?

You may find this helpful:

http://msdn2.microsoft.com/en-us/lib...39(VS.71).aspx
Oct 13 '07 #5
ATT wrote:
[...]
The second section of the code is on the child form. When doing the test, I
can see my text updated with the current position of the cursor. But it does
not update the text on other child forms. The text is updated only for its
own window. How can I make all the child form see the same message?
As I mentioned in my suggestion, the event needs to be static, so that
all form instances are using the same event.

Personally, I would just put the event in the form class itself. But if
you want it in a separate class, you can. Doing it that way, you should
either make the separate class a static class (since there's not really
anything in the class that you need to have per-instance), or you should
at least make static the form class's field that stores the reference to
your event handling class.

If you put the event in your form class instead, then you just need to
make the event field itself static.

Pete
Oct 13 '07 #6
Peter,

I got it to work. Thank you for your help.

Anthony.

"Peter Duniho" wrote:
ATT wrote:
[...]
The second section of the code is on the child form. When doing the test, I
can see my text updated with the current position of the cursor. But it does
not update the text on other child forms. The text is updated only for its
own window. How can I make all the child form see the same message?

As I mentioned in my suggestion, the event needs to be static, so that
all form instances are using the same event.

Personally, I would just put the event in the form class itself. But if
you want it in a separate class, you can. Doing it that way, you should
either make the separate class a static class (since there's not really
anything in the class that you need to have per-instance), or you should
at least make static the form class's field that stores the reference to
your event handling class.

If you put the event in your form class instead, then you just need to
make the event field itself static.

Pete
Oct 14 '07 #7

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

Similar topics

9
by: Randell D. | last post by:
Folks, I'm working on a contact name/address database whereby a slimed down list is shown in the main window. When a record is selected, the complete record is displayed in a new window via a...
1
by: ian.michel | last post by:
I have a parent window that pushes a new window object onto an Array with the following code : OpenChild() { //totalNumWindowsCreated is global totalNumWindowsCreated =...
2
by: Bostonasian | last post by:
I am trying to append options to dropdown in parent window from option items in child window. In parent window, I have following code: <script language="javascript"> function...
1
by: Tomas Vera | last post by:
Hello All, I'm working on a web app that will simulate a Windows app. One of the items that I've trouble reproducing is the parent/child interaction that might occur between a windo and popup...
4
by: Bonj | last post by:
Further to my last post, I have managed to get a child window to display. But its messages are routed to the same WNDPROC that the main window's messages are routed to - what is the way of...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
7
by: Paul | last post by:
Hello, I'm coming from a PHP background and am working on a large-scale VB.NET project. One of the cornerstones of this project is a reusable form class, to standardize our web forms. My goal...
2
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post by:
vs2005, c# Trying to understand why one way works but the other doesnt. I have not tried to create a simpler mdi/child/showdialog app for posting purposes (I think even this would not be so small...
4
by: Buddha | last post by:
Hello, I posted this on two forums, without too much help .. and I am kinda stuck in this. I need to refresh the parent page from the second child window which is opened by the first child and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.