473,750 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4499
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.co m

"Ori" <or*******@hotm ail.com> wrote in message
news:b4******** *************** ***@posting.goo gle.com...
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
4920
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> <title>Test</title> </head> <body> <form method="post" action="javascript:">
2
5512
by: Keith Smith | last post by:
Is there a sure-fire way to trap keypress events no matter which control has focus?
3
3121
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 no data so now rows are seen, all keys are causing my this.OnKeyUp(...) to be invoked correctly. But when the DataGrid is populated with some data (rows are seen with only DataGridTextBoxes), only several keys are causing it to be invoked.
2
4109
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
8495
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
3856
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 some one tell me why & how can it be done? best regards, habix
13
6087
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 sub form_keypressed(keyascii as integer) if keyascii = 13 then 'for the enter key call button_click
2
2354
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: Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp If e.KeyCode = Keys.Return Then
2
19295
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 have created for this purpose is derived from class UserControl.
0
8999
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
8836
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
9575
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...
1
9338
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
9256
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
8260
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...
0
6080
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();...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2223
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.