473,385 Members | 2,162 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,385 software developers and data experts.

Sending events to parent form even when a dialogue is open

Hello guys

I have some custom events in my application i.e. KeyPress such as full screen for pressing F11 and so on. Currently this works fine but only when the main form which is listening tot he KayPress events. I would like this to work even when a Dialogue window is open from this form for example I am opening a child window with Show.Dialogue(). This is blocking the events from going to the parent form.

Can someone please put me in the right direction or give some hints on this.

Thanks in advance.
Dec 31 '08 #1
8 6628
sorry guys I was meant to type:

ShowDialog();

in my above post. This is what I am using to show the form as a dialog.

thanks
Dec 31 '08 #2
Plater
7,872 Expert 4TB
Well the point of a dialog is to force users to only be able to interact with THAT form, otherwise you would just use .Show()

You could consider capturing events on that Dialog and then pipe them back to the parent window.
Dec 31 '08 #3
This sounds okay to me, but how would I send the same event back tot he paren form? i.e. lets say I have this KeyDown event of F11 how would I send it back to parent form when the Dialog is open?

help appreciated.
Dec 31 '08 #4
Plater
7,872 Expert 4TB
In your case it might be rather easy.
Attach an event handler to the dialog form in the parent form.

Something like:
Expand|Select|Wrap|Line Numbers
  1. mydialogform d = new mydialogform();
  2. d.KeyPress+=new KeyPressEventHandler(d_KeyPress);
  3. d.ShowDialog();
  4.  
Then in your d_keypress function you can perform the same checks for F11(and etc)

Actually, you might be able to RE-USE the same keypress event handler you have for the parent form, by also attaching it to dialogform.
Dec 31 '08 #5
Hello

I know this an old post, but rather than creating a new thread I think its better to extend this one as the question is relted to the above subject as well.

The above mentioned method to pipe through the KeyPress events to the Parent works like a charm, but it gets rather painful when there are a lot of Dialogue forms in the application. I was wondering if there is a way to capture events globally within the application, such that the keypress events are also forwarded to the Parent form. Reason for having such a global control is that I will be having Dialogues generated by the Dialogues of the Parent form i.e. Dialogue in another layer of Dialogue like a grand child. It makes the events piping a little messy as I would have to attach listner for each instance.

I have searched this forum for an answer to my question but I could only find something that is related to global events listner from CodeProject: http://www.codeproject.com/KB/cs/globalhook.aspx

I think it only send events to the application as a whole which means the events will go to the currently active Dialgue/Form and the parent Form in this case may not be the active Form. So is there any solution to my problem?
Apr 22 '09 #6
Plater
7,872 Expert 4TB
You could try using "global hooks":
http://www.codeproject.com/KB/cs/globalhook.aspx

You would not need to attach event handlers everywhere then
Apr 22 '09 #7
Thanks a lot,

Sorry I posted before testing the application, the project on CodeProject does provide the solution to my problem.

Thanks
Apr 22 '09 #8
Hello

I have been thinking of finding a slightly different way of finding a way to send those KeyDown events to the parent Form rather than using that "global hooks" mecahnism from codeproject:
http://www.codeproject.com/KB/cs/globalhook.aspx

I tried to create a custom events using Delegate, and crated and listener for it in the parent Form, a method to invoke the event is created in the sub child Form or any other Form. When the event is knvoked I can see that the Parent Form can listen to the event, I am also able to send KeyPressArgs in the events to find which key was pressed.

However this custom event I build will be resideing in a Static class, so that it is visible to all Forms in the application. I was wondering if this is a good way to go about my problem? as in it wouldn't effect or create a new problem for me? I would very much appreciate your view on this, as I do not have a lot of experience with C#.

Thanks
Apr 27 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
0
by: Reimar Bauer | last post by:
Dear all I have written a data handling tool in php and probably you all know already what are my problems. Lets explain: I have found some strange behaviour in Internet Explorer filling...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
12
by: Ger | last post by:
My dialogue form (sometimes partly, sometimes as a whole) remains visible during a fairly long processing job. The dialogue asks the user to enter some data for the job to follow, and after OK,...
18
by: Brett | last post by:
What are reasons to create your own events? Why not just call a class method/function instead? Thanks, Brett
2
by: Mike | last post by:
Greetings, It would seem that this topic has been discussed at some length, but I was unable to discern whether there was a clear cut solution to resolve and/or otherwise workaround the issue. ...
1
by: Richard | last post by:
Greetings. I am total newbie to Javascript so what is written below is probably a bunch of cobblers!! Any assistance in correcting my code much appreciated. I wish the popped up child to pass...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.