PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: John Waalkes on June 27, 2010, 09:11:12 PM

Title: Trapping keystrokes in a TreeView control
Post by: John Waalkes on June 27, 2010, 09:11:12 PM
Hi guys,

I'm trying to trap the Delete key in a TreeView control (so that I can use that to delete an item from the tree).

In the function's parameters, I see that we have this:

"ByVal lpTVKB  As TV_KEYDOWN Ptr  _  ' pointer to TV_KEYDOWN"

How do I go about using lpTVKB in my program?


Edit:

I'm able to trap the key that I want using this:

If (GetKeyState(%VK_DELETE) And &H8000) Then
   lResult& = MsgBox("Hi there")
End If


But how would I go about using the pointer?

Thanks!

John
Title: Re: Trapping keystrokes in a TreeView control
Post by: Paul Squires on June 27, 2010, 09:31:01 PM
Something like this......


'--------------------------------------------------------------------------------
Function FRMMAIN_TREEVIEW1_TVN_KEYDOWN ( _
                                       ControlIndex  As Long,           _  ' index in Control Array
                                       hWndForm      As Dword,          _  ' handle of Form
                                       hWndControl   As Dword,          _  ' handle of Control
                                       ByVal lpTVKB  As TV_KEYDOWN Ptr  _  ' pointer to TV_KEYDOWN
                                       ) As Long

   Select Case @lpTVKB.wvKey
      Case %VK_DELETE
         ? "delete pressed"
      Case %VK_DOWN
         ? "down pressed"
      Case %VK_UP
         ? "up pressed"
      'case
      '  etc....   
   End Select
     
End Function

Title: Re: Trapping keystrokes in a TreeView control
Post by: John Waalkes on June 28, 2010, 01:32:48 PM
Great!, thank you Paul.


John