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

MessageBox with KeyUp and Form with KeyPreview

Ori
Hi Guys,
Here is my problem, but maybe someone can help me with this.

Background:
1. Using C#.
2. I'm having a form which the KeyPreview is on (and must stay like
this) and I'm implementing some functions on the Key up event of some
controls and the form.
The Problem starts when I display a messagebox on the form. Now, when
the user click either "Enter" or "Esc" on the message box, the
messagebox is disappear on the KeyDown event and leaving the keyup
event to the parent form or to the control which was in focus before
we display the message box. Now remember, this problem occur only when
we use the keyboard (we don't have a mouse in the system, everything
is done with the keyboard).

Please note, it turns out that the "Enter" and the "Esc" keys doesn't
fire the keydown event so we can't look to whether we had a keydown on
the form before and only if we had a keydown we perform the keyup
event. We need to find another solution.

We looking to find a way to know that the keyup event occurred on the
messagebox and ignore it.

Does anyone know how to solve this problem?

Thanks,

Ori.
Nov 16 '05 #1
1 4459
Ori,

It sounds like a bug to me. If you can post a small example, I can get
it in the bug system at MS (MSDN product feedback center).

To work around your problem, it would be easy. Basically, on your form,
you have an instance method that would fire the message box. In it, it
would set a flag to true, indicating that the messagebox is shown, then show
the messagebox. In the keyup event handler, only perform the logic if the
flag is true, and always make sure to set the flag to false when done.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ori" <or*******@hotmail.com> wrote in message
news:b4**************************@posting.google.c om...
Hi Guys,
Here is my problem, but maybe someone can help me with this.

Background:
1. Using C#.
2. I'm having a form which the KeyPreview is on (and must stay like
this) and I'm implementing some functions on the Key up event of some
controls and the form.
The Problem starts when I display a messagebox on the form. Now, when
the user click either "Enter" or "Esc" on the message box, the
messagebox is disappear on the KeyDown event and leaving the keyup
event to the parent form or to the control which was in focus before
we display the message box. Now remember, this problem occur only when
we use the keyboard (we don't have a mouse in the system, everything
is done with the keyboard).

Please note, it turns out that the "Enter" and the "Esc" keys doesn't
fire the keydown event so we can't look to whether we had a keydown on
the form before and only if we had a keydown we perform the keyup
event. We need to find another solution.

We looking to find a way to know that the keyup event occurred on the
messagebox and ignore it.

Does anyone know how to solve this problem?

Thanks,

Ori.

Nov 16 '05 #2

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

Similar topics

34
by: Andrew DeFaria | last post by:
I thought this would be fairly straight forward but apparently it's not. Given the following html file: <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head>...
2
by: Keith Smith | last post by:
Is there a sure-fire way to trap keypress events no matter which control has focus?
3
by: Sharon | last post by:
I’m using a DataGrid control on my form; and I want to handle the KeyUp event. So I did: myDataGrid.KeyUp += new KeyEventHandler(this.OnKeyUp); When the DataGrid is empty, I mean when It has...
2
by: ZS | last post by:
Hi, On a form , I'm trying to trap when a shift key is pressed. Can someone explain how the KeyUp,KeyDown and Key Press event works for Forms. Thanks -ZS
4
by: Serdge Kooleman | last post by:
How to get "Key press" event when i'm working with DataGrid (winforms). Seems to me that standard events "KeyUp, KeyPress" are ignored :-( Thank you
13
by: HABJAN ®iga | last post by:
I'am using form's keypreview property & keydown (on form) to look for hotkeys (alt+?) Everything works fine, except when i have focus on combobox. Then the event on form isn't raised. Can...
13
by: Himselff | last post by:
Hi guys, Im new to dot net and wondering how i could remake the same way i was in vb6, capture all keypress whitin a form, per exemple i was on the form looking for some keypress privete...
2
by: Adam J. Schaff | last post by:
I have recently noticed an unwanted behavior that I do not know how to get rid of. To Recreate Problem: Windows Forms App with 2 forms. Form 1 has nothing on it and this code underneath: ...
2
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.