473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to capture key

Hi there,

Can someone enlighten me on how to trap a keystroke in my "PropertyGr id"
override. I see functions or properrites at the control or form level
called:

OnKeyDown
OnKeyPress
OnKeyUp
OnPreviewKeyDow n
ProcessKeyPrevi ew
ProcessDialogKe y
ProcessCmdKey
KeyPreview
IsInputKey

and there are probably more. I've overrided "OnKeyDown( )" in my derived
"PropertyGr id" class but it's not being called. Some others are called
however such as "ProcessCmd Key" but I need to understand what's going on
here (since I suspect that "OnKeyDown( )" is really the correct function).
Can anyone point me in the right direction. Thanks.
Apr 12 '07 #1
8 9644
Hello Larry,

the MS PropertyGrid has an internal grid and this is this one that
receives the keyboard events. If you really want to have a handler for
those events, you can access the internal grid (type is
System.Windows. Forms.PropertyG ridInternal.Pro pertyGridView) with
myPropGrid.Cont rols[2]. But depending on your needs, this can be
tricky to play inside the private parts of the grid.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
On Apr 12, 10:47 am, "Larry Smith" <no_spam@_nospa m.comwrote:
Hi there,

Can someone enlighten me on how to trap a keystroke in my "PropertyGr id"
override. I see functions or properrites at the control or form level
called:

OnKeyDown
OnKeyPress
OnKeyUp
OnPreviewKeyDow n
ProcessKeyPrevi ew
ProcessDialogKe y
ProcessCmdKey
KeyPreview
IsInputKey

and there are probably more. I've overrided "OnKeyDown( )" in my derived
"PropertyGr id" class but it's not being called. Some others are called
however such as "ProcessCmd Key" but I need to understand what's going on
here (since I suspect that "OnKeyDown( )" is really the correct function).
Can anyone point me in the right direction. Thanks.

Apr 12 '07 #2
the MS PropertyGrid has an internal grid and this is this one that
receives the keyboard events. If you really want to have a handler for
those events, you can access the internal grid (type is
System.Windows. Forms.PropertyG ridInternal.Pro pertyGridView) with
myPropGrid.Cont rols[2]. But depending on your needs, this can be
tricky to play inside the private parts of the grid.
Thanks for the feedback. Are you saying that this particular control doesn't
follow the normal (and expected) rules IOW. I'm not sure why they would do
this since it's abnormal to say the least. In any case, if you know this for
a fact (have you confirmed it with MSFT?) then I'll have to rely on
"ProcessCmdKey( )" instead. I'd rather not rely on undocumented techniques.

On a completely unrelated matter however, I know that individual
"PropertyGr id" rows can't be colorized. Do you know a way to pull this off
even if I have to rely on undocumented techniques. I've looked into it and
can't find a way so far (since there seems to be no stable row-based window
behind the scenes until the user actually starts editing the row). Note that
I'm a very experienced C++ developer so hacking into it won't be a problem
if you can get me started (it's a necessary evil I need to explore). Thanks.
Apr 12 '07 #3
Hello Larry,

Why do you say it's abnormal? The internal grid has the focus so this
is absolutely normal that it gets the keyboard events.
Indeed I think you're better to rely on a public solution. But you
should override ProcessKeyPrevi ew instead of ProcessCmdKey which is
more intended for command keys (accelerator and menu shortcuts).
ProcessKeyPrevi ew gives the opportunity to the parent to process the
key before or instead of the child.

Concerning colors, you won't be able to change them on a per property
basis. Sorry for the plug but only a solution like Smart PropertyGrid
will let you customize most of the aspects of the grid. Getting into
the internals of the MSPG has its limits.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
On Apr 12, 2:59 pm, "Larry Smith" <no_spam@_nospa m.comwrote:
the MS PropertyGrid has an internal grid and this is this one that
receives the keyboard events. If you really want to have a handler for
those events, you can access the internal grid (type is
System.Windows. Forms.PropertyG ridInternal.Pro pertyGridView) with
myPropGrid.Cont rols[2]. But depending on your needs, this can be
tricky to play inside the private parts of the grid.

Thanks for the feedback. Are you saying that this particular control doesn't
follow the normal (and expected) rules IOW. I'm not sure why they would do
this since it's abnormal to say the least. In any case, if you know this for
a fact (have you confirmed it with MSFT?) then I'll have to rely on
"ProcessCmdKey( )" instead. I'd rather not rely on undocumented techniques.

On a completely unrelated matter however, I know that individual
"PropertyGr id" rows can't be colorized. Do you know a way to pull this off
even if I have to rely on undocumented techniques. I've looked into it and
can't find a way so far (since there seems to be no stable row-based window
behind the scenes until the user actually starts editing the row). Note that
I'm a very experienced C++ developer so hacking into it won't be a problem
if you can get me started (it's a necessary evil I need to explore). Thanks.

Apr 12 '07 #4
Thanks again for the feedback.
Why do you say it's abnormal? The internal grid has the focus so this
is absolutely normal that it gets the keyboard events.
I say it's abnormal because an "OnKeyDown( )" override should be called
AFAIK. It's a published function which originates from the "Control" base
class no less. Unless I'm missing something I don't see why it's not being
called.
Indeed I think you're better to rely on a public solution. But you
should override ProcessKeyPrevi ew instead of ProcessCmdKey which is
more intended for command keys (accelerator and menu shortcuts).
ProcessKeyPrevi ew gives the opportunity to the parent to process the
key before or instead of the child.
My control is self-contained so it needs to handle its own keystrokes. I've
already played with "ProcessKeyPrev iew()" but will take another look. Since
it's low-level however I figured that "OnKeyDown( )" was likely more
appropriate. The variety of keystroke functions/properties available is
bewildering given the absence of adequate documentation.
Concerning colors, you won't be able to change them on a per property
basis. Sorry for the plug but only a solution like Smart PropertyGrid
will let you customize most of the aspects of the grid. Getting into
the internals of the MSPG has its limits.
You're right of course and I'm puzzled why MSFT never gave us control over
this (color, font, etc.). It's basic. It's also particularly important for
my own app so I'll likely replace "PropertyGr id" by the second release
(first release is pending this fall). Note that I didn't pursue your own
control for a variety of reasons not the least of which is that it came to
my attention too late. I also require localization in potentially many
languages. What languages does yours support? Note BTW (FYI) that Mark
Rideout (manager of the "DataGridVi ew" control at MSFT) has also posted
this:

http://blogs.msdn.com/markrideout/ar...08/510700.aspx

It's unofficial and likely needs work (haven't looked at it in detail) but
it serves as an excellent starting point to replace the "PropertyGr id"
(IMO). Thanks again for your help.
Apr 12 '07 #5
No, OnKeyDown() shouldn't be called for the PropertyGrid. The
PropertyGrid acts as a container (the PropertyGrid class) and is
composed of the toolstrip, the internal grid and the label (comment
area). When the internal grid has the focus, it receives the keyboard
events and handle them. The parent container's virtual methods like
OnKeyDown won't be called simply because the keystrokes are not
directed to it. To be aware of the keys typed, you can override
ProcessKeyPrevi ew or subscribe to the events of the internal grid
(Controls[2].KeyDown += ......). But not that in the second
possibility, the keys will still be handled by the child. In the first
solution you can "eat" the keys messages.

So, this is what happens normally. However I agree that MS should have
provided a way to make the container aware of these events in a more
"natural" way. FYI, SPG forwards the events automatically to the
parent.

Concerning localization, neither SPG or MSPG support a particular
language. This is up to the client application to load the correct
strings and to supply them via Description and DisplayName attributes.
Note that SPG also enables on the fly modification of these
properties.

Hope that helps.

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
On Apr 12, 5:43 pm, "Larry Smith" <no_spam@_nospa m.comwrote:
Thanks again for the feedback.
Why do you say it's abnormal? The internal grid has the focus so this
is absolutely normal that it gets the keyboard events.

I say it's abnormal because an "OnKeyDown( )" override should be called
AFAIK. It's a published function which originates from the "Control" base
class no less. Unless I'm missing something I don't see why it's not being
called.
Indeed I think you're better to rely on a public solution. But you
should override ProcessKeyPrevi ew instead of ProcessCmdKey which is
more intended for command keys (accelerator and menu shortcuts).
ProcessKeyPrevi ew gives the opportunity to the parent to process the
key before or instead of the child.

My control is self-contained so it needs to handle its own keystrokes. I've
already played with "ProcessKeyPrev iew()" but will take another look. Since
it's low-level however I figured that "OnKeyDown( )" was likely more
appropriate. The variety of keystroke functions/properties available is
bewildering given the absence of adequate documentation.
Concerning colors, you won't be able to change them on a per property
basis. Sorry for the plug but only a solution like Smart PropertyGrid
will let you customize most of the aspects of the grid. Getting into
the internals of the MSPG has its limits.

You're right of course and I'm puzzled why MSFT never gave us control over
this (color, font, etc.). It's basic. It's also particularly important for
my own app so I'll likely replace "PropertyGr id" by the second release
(first release is pending this fall). Note that I didn't pursue your own
control for a variety of reasons not the least of which is that it came to
my attention too late. I also require localization in potentially many
languages. What languages does yours support? Note BTW (FYI) that Mark
Rideout (manager of the "DataGridVi ew" control at MSFT) has also posted
this:

http://blogs.msdn.com/markrideout/ar...08/510700.aspx

It's unofficial and likely needs work (haven't looked at it in detail) but
it serves as an excellent starting point to replace the "PropertyGr id"
(IMO). Thanks again for your help.

Apr 12 '07 #6
No, OnKeyDown() shouldn't be called for the PropertyGrid. The
PropertyGrid acts as a container (the PropertyGrid class) and is
composed of the toolstrip, the internal grid and the label (comment
area). When the internal grid has the focus, it receives the keyboard
events and handle them. The parent container's virtual methods like
OnKeyDown won't be called simply because the keystrokes are not
directed to it. To be aware of the keys typed, you can override
ProcessKeyPrevi ew or subscribe to the events of the internal grid
(Controls[2].KeyDown += ......). But not that in the second
possibility, the keys will still be handled by the child. In the first
solution you can "eat" the keys messages.
Ok, thanks for the primer. While I don't agree with this behaviour (it's
inconsistent and counterintuitiv e) we live in a world of imperfection.
So, this is what happens normally. However I agree that MS should have
provided a way to make the container aware of these events in a more
"natural" way. FYI, SPG forwards the events automatically to the
parent.
How easy would it be to port my code to your grid. Is it compatible with the
native grid (can we feed it the same way) or am I'm faced with a lot of
redevelopment. Note that I've rolled my own custom "TypeConver ter" and
"TypeDescriptio nProvider" classes (overrding "GetProperties( )" where req'd)
and I don't want to tear it all apart at this stage (since it's working
now).
Concerning localization, neither SPG or MSPG support a particular
language. This is up to the client application to load the correct
strings and to supply them via Description and DisplayName attributes.
Note that SPG also enables on the fly modification of these
properties.
Ok, thanks. I didn't know whether your grid had any of its own native
strings or not.
Apr 12 '07 #7
Larry,

if you want to know more about SPG I propose that you contact me
through the VisualHint helpdesk. I don't think this is the proper
place here... ;)

Best regards,

Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
On Apr 12, 7:33 pm, "Larry Smith" <no_spam@_nospa m.comwrote:
No, OnKeyDown() shouldn't be called for the PropertyGrid. The
PropertyGrid acts as a container (the PropertyGrid class) and is
composed of the toolstrip, the internal grid and the label (comment
area). When the internal grid has the focus, it receives the keyboard
events and handle them. The parent container's virtual methods like
OnKeyDown won't be called simply because the keystrokes are not
directed to it. To be aware of the keys typed, you can override
ProcessKeyPrevi ew or subscribe to the events of the internal grid
(Controls[2].KeyDown += ......). But not that in the second
possibility, the keys will still be handled by the child. In the first
solution you can "eat" the keys messages.

Ok, thanks for the primer. While I don't agree with this behaviour (it's
inconsistent and counterintuitiv e) we live in a world of imperfection.
So, this is what happens normally. However I agree that MS should have
provided a way to make the container aware of these events in a more
"natural" way. FYI, SPG forwards the events automatically to the
parent.

How easy would it be to port my code to your grid. Is it compatible with the
native grid (can we feed it the same way) or am I'm faced with a lot of
redevelopment. Note that I've rolled my own custom "TypeConver ter" and
"TypeDescriptio nProvider" classes (overrding "GetProperties( )" where req'd)
and I don't want to tear it all apart at this stage (since it's working
now).
Concerning localization, neither SPG or MSPG support a particular
language. This is up to the client application to load the correct
strings and to supply them via Description and DisplayName attributes.
Note that SPG also enables on the fly modification of these
properties.

Ok, thanks. I didn't know whether your grid had any of its own native
strings or not.

Apr 13 '07 #8
if you want to know more about SPG I propose that you contact me
through the VisualHint helpdesk. I don't think this is the proper
place here... ;)
Yes, this isn't the proper venue. Will be in touch in the near future.
Thanks again for your help here.
Apr 13 '07 #9

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

Similar topics

0
1502
by: Mark Barinstein | last post by:
Hello. W2K, db2 v7, FP10a. Before now our replication worked properly. But some days ago capture suddenly stopped loggin and filling cd tables without any messages. The last message was like this: -- 2004-03-03-09:17:36 ASN0105I: Data that has been copied was pruned from the change data table ASN.IBMSNAP_UOW at SEQ = 00000000006EFDC2DB55 for 2
2
5984
by: Jose | last post by:
There's something for me to learn with this example, i'm sure :) Given this text: "....." and my first attempt at capture the groups: "(?:\)" RegExTest gives me what i expect: 6 captured groups: Contact, Region, All ContractRegion, ASIA PACIFIC, Japan, Japan. However, with this C# code, i just get 2 capture groups: ",
0
2707
by: Tsunami | last post by:
Hi to all: I have a big problem and I write to ask for help. Sorry if this message does not arrive to the apropriate group. I have selected them paying attention but I am not sure to do it well. I want to capture a fotogram of a media player control in VB6 and I capture the screen as in the section "Visual Basic 4.0 16/32 Capture Routines" of this URL:
4
3371
by: jxiang | last post by:
I created a child form that is much bigger than the MDI form in VB.Net. I am trying to capture the whole child form and save as an image or sent to printer. I tried to use BitBlt to capture the child form but I can only capture the visible part of the child form whatever you scroll to any part of the form. I have read the article in site http://www.fengyuan.com/article/wmprint.html unforturely it is for C++ instead of VB.Net. I tried to...
2
2416
by: py | last post by:
I need to take a screen shot of the computer screen. I am trying to use PIL and I saw there is ImageGrab...however it only works on Windows. Is there a platform-independent ability to work around this? thanks
4
5374
by: gwhite1 | last post by:
I use this code to capture a screen in a regular VB 2005 windows app. It works great! I found the code in google. But when I create a windows service it does not capture the screen. It only captures a blank graphic. Does anyone know why it will not capture the current screen? Is something not available when running as a service? Thanks!!! Sheila Function CreateScreenshot() As System.Drawing.Bitmap Dim Rect As System.Drawing.Rectangle =...
0
1828
by: Roger | last post by:
I am in the process of installing DB2 Replication V 8.2 for Z/os on my test system. When I start the ASNSTRC (capture) with RRS shutdown, it switches to CAF and starts up. However, if I have RRS runing , then it gives the following error : ASN0600I "Capture" : "" : "Initial" : Program "capture 8.2.4 (APAR pk34406, AS ASN0530E "Capture" : "ASN" : "Initial" : The program could not 076 connect to database "DB2T" with USERID "N/A" ....
0
3503
by: j101 | last post by:
I am attempting to set up Q Capture on RH Linux (x86_64) using DB2 9 fp2, but there seems to be a general problem loading a specify MQ shared library "/opt/mqm/lib/libmqm_r.so". I have MQ v6 installed in the default directory and working. I can generate the similar errors in two ways (1) through the Replication Center attempting to validate the Q objects and (2) after manually creating the Q objects and running the asnqcap program. ...
2
7327
by: pampululu | last post by:
hello, I try to use directx.capture in my web application, I use visual studio web developper 2005 express with c# for code behind. I can list the webcam available on computer, no probem, my probem is to capture and display webcam in a control I tried like this: protected void Page_Load(object sender, EventArgs e) { Filters filters = new Filters(); Capture capture = new Capture(filters.VideoInputDevices,
1
3394
by: sangith | last post by:
Hi, I tried the packet capture module program. I did a file transfer using ftp from this host to another server. But when I ran the program, it was just hanging off and it did not print the src ip, dst ip, src port, dst port. Should I run this program as a Daemon? If so, how do I do that? I would appreciate your response.
0
9680
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
10456
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...
0
10230
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
10174
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
10012
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...
1
7548
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
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.