N
Neil Stevens
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 PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
Select Case m.Msg
Case CGlobals.WindowsMessages.KeyDown
Select Case m.WParam.ToInt32
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.addmessagefilter, 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
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 PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boolean Implements System.Windows.Forms.IMessageFilter.PreFilterMessage
Select Case m.Msg
Case CGlobals.WindowsMessages.KeyDown
Select Case m.WParam.ToInt32
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.addmessagefilter, 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