- I am able to display ContextMenuScript (CMS) successfully outside windows form.
- I can Select/Click items using mouse pointer.
- However, it doesn't likes keyboard control (arrow up/down, escape) when form is not focused.
- If the form is focused and CMS showed, then keyboard can control it but not when not focused :(.
- I need help with code which will help to achieve this without form being focused.
Regards
Public Const CTRL_Key As Integer = &H2
Public Const Hot_Key As Integer = &H312
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
Private Sub Hot_Key_Register() Handles MyBase.Load
RegisterHotKey(Me.Handle, 100, CTRL_Key, Keys.NumPad1)
RegisterHotKey(Me.Handle, 200, CTRL_Key, Keys.NumPad2)
RegisterHotKey(Me.Handle, 300, CTRL_Key, Keys.NumPad3)
End Sub
Protected Overrides Sub WndProc(ByRef Window_Message As Message)
If Window_Message.Msg = Hot_Key Then
Dim id As IntPtr = Window_Message.WParam
Select Case (id.ToString)
Case "100"
CMS_01.Show(Cursor.Position.X, Cursor.Position.Y)
Case "200"
CMS_02.Show(Cursor.Position.X, Cursor.Position.Y)
Case "300"
CMS_03.Show(Cursor.Position.X, Cursor.Position.Y)
End Select
End If
MyBase.WndProc(Window_Message)
End Sub