473,801 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1572
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******** ********@TK2MSF TNGP10.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@_spamkille r_bobpowell.net > wrote in message
news:Oa******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP10.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******** **********@TK2M SFTNGP09.phx.gb l...
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@_spamkille r_bobpowell.net > wrote in message
news:Oa******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP10.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@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP11.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******** **********@TK2M SFTNGP09.phx.gb l...
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@_spamkille r_bobpowell.net > wrote in message
news:Oa******** ******@TK2MSFTN GP10.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******** ********@TK2MSF TNGP10.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
10550
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 using "onkeypress=myKeypressHandler()" but, beyond that, I'm stuck. I forget how to detect what key was pressed or how to "null it out". I'm using IE6 and users will be IE5.0 upward ONLY (trust me on this, suffice to say it's not a website but...
15
4058
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 CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
1
4975
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 (using async callback request aka XmlHttp in other browsers) implemented on my custom tab ( read: on my asp.net page, which added to communicator tabs) - it's very usefull during search for communicator users. I added javascript event handlers on...
3
3348
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 want to make Keyboard shortcuts for the application. The problem is that of course, whle the user is using his other software and the clock is showing in a small form on the screen, it doesn't have focus and "KeyPress" or "KeyDown" doesn't have...
0
10292
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10262
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
10052
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
9101
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...
1
7589
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6829
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
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2959
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.