473,659 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IMessageFilter question

Hi,

I am in the process of developing a popup utility for a project i am working on, the basic idea is that when a user presses the control key a popup menu will be displayed listing the shortcut options, for example Ctrl+Q which will be used to close a window.

The popup is a simple form which is configured by means of of a dictionary of values (key and description).

I have a message filter running to intercept the key down presses for the control keys as a single instance of the popup will be associated to all forms in the application and it will handle the common events and displaying of the form but will raise events down to the implementing class or form to create the popup menu and process the resulting action.

What i would like to know is this, how can i determine in the message filter which controls key has been pressed, i have the following code which determines a keydown and a control key but i need to determine which control key is pressed because the right control key will activate the popup instantly and the left will activate it after a delay if the key is held down.

Public Class MessageFilter
Implements IMessageFilter

Public Function PreFilterMessag e(ByRef m As System.Windows. Forms.Message) As Boolean Implements System.Windows. Forms.IMessageF ilter.PreFilter Message
Select Case m.Msg
Case CGlobals.Window sMessages.KeyDo wn
Select Case m.WParam.ToInt3 2
Case Keys.ControlKey
MsgBox("Control Key")
End Select
End Select
Return False
End Function
End Class

This is in a MessageFilter class and is added to application.add messagefilter, i have this working fine and get the message box whenever the control keys are pressed but i cant figure out how to get whether the left or right control key has been pressed.

I would greatly appreciate any help that you can give

Thanks in advance
Neil
Nov 20 '05 #1
1 2649
Check for a WM_KEYDOWN message for the control key
(which you already do) and examine bit 24 of the lParam parameter
It is 1 for the right ctrl key and 0 for the left ctrl key
Save the state until you get the corresponding WM_KEYUP

BTW, please don't post in HTML

/claes


"Neil Stevens" <ne**********@b lueyonder.co.uk > wrote in message
news:O$******** ******@tk2msftn gp13.phx.gbl...
Hi,

I am in the process of developing a popup utility for a project i am working
on, the basic idea is that when a user presses the control key a popup menu
will be displayed listing the shortcut options, for example Ctrl+Q which
will be used to close a window.

The popup is a simple form which is configured by means of of a dictionary
of values (key and description).

I have a message filter running to intercept the key down presses for the
control keys as a single instance of the popup will be associated to all
forms in the application and it will handle the common events and displaying
of the form but will raise events down to the implementing class or form to
create the popup menu and process the resulting action.

What i would like to know is this, how can i determine in the message filter
which controls key has been pressed, i have the following code which
determines a keydown and a control key but i need to determine which control
key is pressed because the right control key will activate the popup
instantly and the left will activate it after a delay if the key is held
down.

Public Class MessageFilter
Implements IMessageFilter

Public Function PreFilterMessag e(ByRef m As
System.Windows. Forms.Message) As Boolean Implements
System.Windows. Forms.IMessageF ilter.PreFilter Message
Select Case m.Msg
Case CGlobals.Window sMessages.KeyDo wn
Select Case m.WParam.ToInt3 2
Case Keys.ControlKey
MsgBox("Control Key")
End Select
End Select
Return False
End Function
End Class

This is in a MessageFilter class and is added to
application.add messagefilter, i have this working fine and get the message
box whenever the control keys are pressed but i cant figure out how to get
whether the left or right control key has been pressed.

I would greatly appreciate any help that you can give

Thanks in advance
Neil
Nov 20 '05 #2

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

Similar topics

1
3766
by: See Sharp | last post by:
Hello all, I have a form class that implements the imessagefilter interface public class frmMain : System.Windows.Forms.Form, IMessageFilter I also have this implemented bool IMessageFilter.PreFilterMessage( ref Message m ) This class actually interacts with the twain driver and that's why I need
7
6461
by: Michael Culley | last post by:
I've added an IMessageFilter to my app but I don't get messages or I get only a few and then it stops. My code is very simple. Am I doing something wrong? public class MF : IMessageFilter { public MF() { } public bool PreFilterMessage(ref Message m) {
0
1051
by: Whitney Kew | last post by:
Hi there, I want to implement the COM interface IMessageFilter from my VB.NET application. I realize that it's inside ole32.dll, and that ole32.dll doesn't have a type library inside of it, so I'm unsure if this is even possible. I'm pretty green to VB.NET, and .NET in general, so would anyone be able to give me a little push? Specifically, I think what I want to do is to somehow "import" ole32.dll into my VB app, but I'm unsure of...
4
16778
by: GrandpaB | last post by:
Hi, I recently had a post about how to block Mousewheel events. The answer was to implement an IMessageFilter. Sadly, I must report that after 24 hours of researching my library and online resources I am still stumped! I did find a promising code snippet on MSDN, but have yet to successfully implement it. Here is the code snippet: Public Class MessageFilter
4
3399
by: ThunderMusic | last post by:
Hi, I'm developping a form that renders differently when hovered and trigger some processing when not hovered (leaved). The thing is, when I leave my form and another form from my application is underneath, it works fine, but if I leave my form and anything that is not from my application is underneath, the Leave event does not fire until I hover something from my application. Here's my filtered code for the IMessageFilter (I did not...
2
3785
by: deciacco | last post by:
IMessageFilter interface allows one to capture messages before they are sent to a control or a form. Is there a way, perhaps by implementing another interface, to capture all messages to an exe. In other words, if I add a custom message filter implementing the IMessageFilter interface to my notifyicon class, I can capture messages when I display forms. If I add custom event handlers to the various events in the SystemEvents class I can...
0
1880
by: ah.ping.luk | last post by:
Dear All, i want to catch the application event (WM_CLOSE) in a user control. i create a class that implement the IMessageFIlter interface as follow: '=================================================== Imports System.Windows.Forms
2
2104
by: bakpao | last post by:
I want to have a form that accepts keypresses. The controls other than the form should not receive any of the user input. I have implemented it using IMessageFilter but now just now I discovered about KeyPreview. What is the difference between IMessageFilter and KeyPreview? Is there a significant benefit using one way than the other?
4
3754
by: =?Utf-8?B?am9obmY=?= | last post by:
Trying to get a see windows messages using IMessageFilter interface however it does not seem to get all window messages. Specifically I am looking for the WM_POWERBROADCAST. I override wndproc which shows the msg successfully but nothing shows up when using IMessageFilter. Am i misunderstanding something? Here is sample code: public class MyFilter : IMessageFilter { const int WM_POWERBROADCAST = 0x0218; public bool...
0
8428
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
8851
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
8747
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
8528
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
8627
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
7356
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
5649
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
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1976
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.