473,586 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best way to get ctl and alt keys in Panel

_DD
I'm trying to gracefully intercept Control and Alt keys for mouse
events within a Panel. I realize that keyboard is not normally
relevant there, but in this case, I need to get Ctrl-LeftMouseButton ,
etc.

This could be intercepted by the form that owns the panel, but that
does not seem very elegant. Are there any alternatives? I could use
another type of base control if necessary. I'm mostly painting
graphics.
Jun 13 '06 #1
2 2292
_DD <_D*@nospam.com > wrote:
I'm trying to gracefully intercept Control and Alt keys for mouse
events within a Panel. I realize that keyboard is not normally
relevant there, but in this case, I need to get Ctrl-LeftMouseButton ,
etc.


You can check the state of Control etc. in the MouseDown/MouseMove event
by checking the Control.Modifie rKeys static property.

-- Barry

--
http://barrkel.blogspot.com/
Jun 13 '06 #2
"_DD" wrote:
I'm trying to gracefully intercept Control and Alt keys for mouse
events within a Panel. I realize that keyboard is not normally
relevant there, but in this case, I need to get Ctrl-LeftMouseButton ,
etc.

This could be intercepted by the form that owns the panel, but that
does not seem very elegant. Are there any alternatives? I could use
another type of base control if necessary. I'm mostly painting
graphics.


If you are trying to determine which modifier keys are pressed when the user
clicks the mouse in your panel: Subscribe to the Panel's MouseDown event.
Then in your event handler, check the status of the Control.Modifie rKeys
static property. For example, to see if the Control key was pressed down
when the mouse was clicked: (Control.Modifi erKeys & Keys.Control) != 0. To
check if the ONLY the control key was pressed: Control.Modifie rKeys ==
Keys.Control.

But if you want to check the state of the modifier keys at a random time
(i.e., not when the mouse was clicked) your job is more difficult because the
panel will only receive key events when it has focus. Since it's not
normally a control that receives focus nor shows that it has focus, this is
tricky. Instead, you can set the form's property form.KeyPreview =true. This
tells the form to intercept key events for all of its child controls before
passing the events on to the focused control. Then subscribe to the form's
KeyDown event to catch all key presses.

--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

Jun 15 '06 #3

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

Similar topics

6
2231
by: a-ok | last post by:
Hi, My client has a product database od around 20000 items. And it is updated every few days when he gets a catalog from the supplier. It's supposed to work like this: if there already is a product in the database with that ID (primary key), just UPDATE the price, and if there is no product with that ID it should do an INSERT for that...
3
2615
by: Amy L. | last post by:
I have a client / server application. I just want to encrypt small amounts of data 1<x<1024 characters or so. I need to load the same Key and IV in both applications. However, both the key and IV are byte arrays. What is the best way to get the keys loaded in both applications? For example in RSA you can export the keys to XML. Can you...
4
5855
by: Neil Wallace | last post by:
Hi there, I have an application in which a grid of 100 or more buttons are put on a form in columns of 10. All the buttons are within a panel. They are added in runtime, and so they adopt a sensible tab value. The tab key moves the focus down the column one by one, and the up and down arrow keys work well.
11
2789
by: Rlrcstr | last post by:
How can you detect when an arrow key gets pressed? Doesn't seem to trigger a KeyPress or KeyDown event. Thanks. Jerry
2
4159
by: Phil Galey | last post by:
I have a Panel control docked on all sides on a form and the panel control contains a PictureBox. I'm using the KeyDown event of the form to respond to the and keys for resizing the image and the PageUp, PageDn, Home, End, and arrow keys for scrolling the Panel control. Resizing the image using the and keys works fine, deriving a resized...
1
1152
by: John Salerno | last post by:
Ok, concerning my little pet project...I have int arrays of the following sizes: panel AND panel They are static fields right now, and I'm wondering if it's possible (and better) to make them separate classes/objects of type Panel.
6
2194
by: Andre Ranieri | last post by:
Hello everyone, I'm wondering if I could get some advice on the best way to build the user interface depicted in this diagram: http://www.senske.com/images/winforms_layout.jpg The gray areas will be static throughout. However, I'd like the blue area to change to a different interface depending on which of the buttons at left is pressed....
2
1448
by: Horace Nunley | last post by:
A wizard? A formView? I wanna capture about a dozen fields of info, then show a "is this information correct" page, then allow edit or save. Which is the best way? I was thinking I could hide the formview and display its information in labels when it came time to ask "is this info correct"?
4
1406
by: brett | last post by:
On a postback, what is the best way to get FORM variables so that there is a key/value structure that allows accessing by key name. For example: INSERT INTO table1 (keys, keys) values (keys.value, keys.value) I need to keep keys and values synchronized and call by variable name. I'm currently doing:
0
7908
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...
0
7836
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...
0
8199
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. ...
1
7950
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...
0
8212
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...
0
6606
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...
1
5710
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...
0
5389
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...
1
1447
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.