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

Keypress sent to wrong window

I have an MDI application which contains a menu, MDI child form and
properties window.

On my Edit menu I have Cut, Copy, Paste, and Delete. The shortcut key for
Delete is set to Del.

In the MDI child form I can select an object and its properties are
displayed in the properties window. All good so far.

If I click in the properties window to edit the properties of my object, I
can type text and use the backspace key, but if I press the Del key to
delete a character, the object is deleted from my MDI child form. This would
seem to be because the code in the menu event handler for Delete calls the
delete method on the MDI child form (which does the delete).

What is the standard way to get the correct behaviour in this scenario? I am
expecting that when the MDI child form has focus then pressing Del will
delete the selected object. But when the properties window has focus I
expect the Del key to work as a normal text editing key.

TIA

Charles

Nov 20 '05 #1
4 1550
Handle ProcessCmdKey in your MDI Child.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Charles Law" <bl**@thingummy.com> wrote in message
news:uM****************@TK2MSFTNGP10.phx.gbl...
I have an MDI application which contains a menu, MDI child form and
properties window.

On my Edit menu I have Cut, Copy, Paste, and Delete. The shortcut key for
Delete is set to Del.

In the MDI child form I can select an object and its properties are
displayed in the properties window. All good so far.

If I click in the properties window to edit the properties of my object, I
can type text and use the backspace key, but if I press the Del key to
delete a character, the object is deleted from my MDI child form. This would seem to be because the code in the menu event handler for Delete calls the
delete method on the MDI child form (which does the delete).

What is the standard way to get the correct behaviour in this scenario? I am expecting that when the MDI child form has focus then pressing Del will
delete the selected object. But when the properties window has focus I
expect the Del key to work as a normal text editing key.

TIA

Charles

Nov 20 '05 #2
Hi Bob

Thanks for the hint. I have looked in MSDN and tried to handle ProcessCmdKey
but my Protected Overrides Function ProcessCmdKey never gets called. Is
there something else I need to do to get it to be called? When it is called,
if I test for the Delete key, how do I get it redirected to the properties
window. Sorry if these are obvious questions, but the fog hasn't quite
cleared yet.

Thanks.

Charles
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:Oa**************@TK2MSFTNGP10.phx.gbl...
Handle ProcessCmdKey in your MDI Child.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Charles Law" <bl**@thingummy.com> wrote in message
news:uM****************@TK2MSFTNGP10.phx.gbl...
I have an MDI application which contains a menu, MDI child form and
properties window.

On my Edit menu I have Cut, Copy, Paste, and Delete. The shortcut key for Delete is set to Del.

In the MDI child form I can select an object and its properties are
displayed in the properties window. All good so far.

If I click in the properties window to edit the properties of my object, I can type text and use the backspace key, but if I press the Del key to
delete a character, the object is deleted from my MDI child form. This would
seem to be because the code in the menu event handler for Delete calls the delete method on the MDI child form (which does the delete).

What is the standard way to get the correct behaviour in this scenario?

I am
expecting that when the MDI child form has focus then pressing Del will
delete the selected object. But when the properties window has focus I
expect the Del key to work as a normal text editing key.

TIA

Charles


Nov 20 '05 #3
Hmm, This means that by the time you see it the command has already been
handled, by your top-level MDI Parent no doubt.

You could ignore the delete if the property grid has the focus.

You may have to change that shortcut though.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Charles Law" <bl**@thingummy.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Bob

Thanks for the hint. I have looked in MSDN and tried to handle ProcessCmdKey but my Protected Overrides Function ProcessCmdKey never gets called. Is
there something else I need to do to get it to be called? When it is called, if I test for the Delete key, how do I get it redirected to the properties
window. Sorry if these are obvious questions, but the fog hasn't quite
cleared yet.

Thanks.

Charles
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:Oa**************@TK2MSFTNGP10.phx.gbl...
Handle ProcessCmdKey in your MDI Child.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Charles Law" <bl**@thingummy.com> wrote in message
news:uM****************@TK2MSFTNGP10.phx.gbl...
I have an MDI application which contains a menu, MDI child form and
properties window.

On my Edit menu I have Cut, Copy, Paste, and Delete. The shortcut key for Delete is set to Del.

In the MDI child form I can select an object and its properties are
displayed in the properties window. All good so far.

If I click in the properties window to edit the properties of my object,
I
can type text and use the backspace key, but if I press the Del key to
delete a character, the object is deleted from my MDI child form. This would
seem to be because the code in the menu event handler for Delete calls the delete method on the MDI child form (which does the delete).

What is the standard way to get the correct behaviour in this

scenario? I
am
expecting that when the MDI child form has focus then pressing Del

will delete the selected object. But when the properties window has focus I
expect the Del key to work as a normal text editing key.

TIA

Charles



Nov 20 '05 #4
The thing is, I see from all sorts of other apps that they behave correctly
in such a situation. I tried it on the VS IDE and all was well.

It makes me think that there must be a way to deal with this because it must
crop up all the time.

Can anyone suggest a way?

Charles
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hmm, This means that by the time you see it the command has already been
handled, by your top-level MDI Parent no doubt.

You could ignore the delete if the property grid has the focus.

You may have to change that shortcut though.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Charles Law" <bl**@thingummy.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Bob

Thanks for the hint. I have looked in MSDN and tried to handle

ProcessCmdKey
but my Protected Overrides Function ProcessCmdKey never gets called. Is
there something else I need to do to get it to be called? When it is

called,
if I test for the Delete key, how do I get it redirected to the properties
window. Sorry if these are obvious questions, but the fog hasn't quite
cleared yet.

Thanks.

Charles
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:Oa**************@TK2MSFTNGP10.phx.gbl...
Handle ProcessCmdKey in your MDI Child.

--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Charles Law" <bl**@thingummy.com> wrote in message
news:uM****************@TK2MSFTNGP10.phx.gbl...
> I have an MDI application which contains a menu, MDI child form and
> properties window.
>
> On my Edit menu I have Cut, Copy, Paste, and Delete. The shortcut key
for
> Delete is set to Del.
>
> In the MDI child form I can select an object and its properties are
> displayed in the properties window. All good so far.
>
> If I click in the properties window to edit the properties of my object,
I
> can type text and use the backspace key, but if I press the Del key

to > delete a character, the object is deleted from my MDI child form. This would
> seem to be because the code in the menu event handler for Delete calls the
> delete method on the MDI child form (which does the delete).
>
> What is the standard way to get the correct behaviour in this

scenario?
I
am
> expecting that when the MDI child form has focus then pressing Del

will > delete the selected object. But when the properties window has focus

I > expect the Del key to work as a normal text editing key.
>
> TIA
>
> Charles
>
>
>



Nov 20 '05 #5

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

Similar topics

4
by: owen | last post by:
I have an <input> box and i want to disable the apostrophe ( ' ) key, so when you press it, no character appears in the input box. All other keys should work ok. I can trap the keypress event...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
1
by: centur | last post by:
Hello. I created simple asp.net application to search message history over Office Live Communicator conversations. I complete quite all job but stick with one thing - I have autosuggest box...
3
by: Zvi | last post by:
Hi! I have a form in an application that's being used for some workers at a call center, that has a small UI. It's just a clock so users on calls can see how long they have been on a call. I...
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
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
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...
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
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...

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.