dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Treeview Macros / Messages for selecting a node - hItem

  1. #1
    Crispin Wright Guest

    Treeview Macros / Messages for selecting a node - hItem


    Public Function TreeView_Select(hWnd As Long, hItem As Long, code As Long)
    As Boolean
    TreeView_Select = SendMessage(hWnd, TVM_SELECTITEM, ByVal code, ByVal hItem)
    End Function

    'The above function is From Brad Martinez's site and works fine....

    'I can't make it work though, I call it like this:

    TreeView_Select TreeView1.hWnd, hNode, TVGN_CARET

    I have all the Definitions and macros in place e.t.c e.t.c are there any
    caveats that I need to look for...

    I have been trying for months to get this functionality to work - I have
    tried sending Messages and using macros but to no avail...I figure there
    must be something i'm missing...

    thanks for your time...

    Crispin

  2. #2
    Jonathan Wood Guest

    Re: Treeview Macros / Messages for selecting a node - hItem

    Where did you get hNode from for your call? This shouldn't be that hard.
    Show a little more of your code, including the SendMessage declaration.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
    "Crispin Wright" <crispin@freediver.co.uk> wrote in message
    news:3b4ad7fc$1@news.devx.com...
    >
    > Public Function TreeView_Select(hWnd As Long, hItem As Long, code As Long)
    > As Boolean
    > TreeView_Select = SendMessage(hWnd, TVM_SELECTITEM, ByVal code, ByVal

    hItem)
    > End Function
    >
    > 'The above function is From Brad Martinez's site and works fine....
    >
    > 'I can't make it work though, I call it like this:
    >
    > TreeView_Select TreeView1.hWnd, hNode, TVGN_CARET
    >
    > I have all the Definitions and macros in place e.t.c e.t.c are there any
    > caveats that I need to look for...
    >
    > I have been trying for months to get this functionality to work - I have
    > tried sending Messages and using macros but to no avail...I figure there
    > must be something i'm missing...
    >
    > thanks for your time...
    >
    > Crispin




  3. #3
    Jonathan Wood Guest

    Re: Treeview Macros / Messages for selecting a node - hItem

    Where did you get hNode from for your call? This shouldn't be that hard.
    Show a little more of your code, including the SendMessage declaration.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
    "Crispin Wright" <crispin@freediver.co.uk> wrote in message
    news:3b4ad7fc$1@news.devx.com...
    >
    > Public Function TreeView_Select(hWnd As Long, hItem As Long, code As Long)
    > As Boolean
    > TreeView_Select = SendMessage(hWnd, TVM_SELECTITEM, ByVal code, ByVal

    hItem)
    > End Function
    >
    > 'The above function is From Brad Martinez's site and works fine....
    >
    > 'I can't make it work though, I call it like this:
    >
    > TreeView_Select TreeView1.hWnd, hNode, TVGN_CARET
    >
    > I have all the Definitions and macros in place e.t.c e.t.c are there any
    > caveats that I need to look for...
    >
    > I have been trying for months to get this functionality to work - I have
    > tried sending Messages and using macros but to no avail...I figure there
    > must be something i'm missing...
    >
    > thanks for your time...
    >
    > Crispin




  4. #4
    Crispin Wright Guest

    Re: Treeview Macros / Messages for selecting a node - hItem


    Glad you're up for it John,

    Funnily enough thats what I thought (shouldn't be that hard) so here's some
    more info:

    hNode comes from the following call:

    hNode = TreeView_GetSelection(TreeView1.hWnd)

    which in turn calls the macro:

    Public Function TreeView_GetSelection(hWnd As Long) As Long
    TreeView_GetSelection = TreeView_GetNextItem(hWnd, 0, TVGN_CARET)
    End Function

    TVGN CARET IS DEFINED AS FOLLOWS:

    Public Enum TVM_GETNEXTITEM_wParam
    TVGN_ROOT = &H0
    TVGN_NEXT = &H1
    TVGN_PREVIOUS = &H2
    TVGN_PARENT = &H3
    TVGN_CHILD = &H4
    TVGN_FIRSTVISIBLE = &H5
    TVGN_NEXTVISIBLE = &H6
    TVGN_PREVIOUSVISIBLE = &H7
    TVGN_DROPHILITE = &H8
    TVGN_CARET = &H9
    #If (Win32_IE >= &H400) Then
    TVGN_LASTVISIBLE = &HA
    #End If
    End Enum


    SendMessage is defined as follows (Ansi Version - hence Alias)

    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    wParam As Any, _
    lParam As Any) As Long

    That enough code for ya?


    BTW - all hNodes are valid, and can be successfully used with other calls
    to do things such embolden a node, or "cut" a node...it's just the SelectItem
    that won't play ball - try TVM_SELECTITEM for yourself, if you can get it
    to work i'll be eternally grateful...thanks again for your time...

  5. #5
    Crispin Wright Guest

    Re: Treeview Macros / Messages for selecting a node - hItem


    Glad you're up for it John,

    Funnily enough thats what I thought (shouldn't be that hard) so here's some
    more info:

    hNode comes from the following call:

    hNode = TreeView_GetSelection(TreeView1.hWnd)

    which in turn calls the macro:

    Public Function TreeView_GetSelection(hWnd As Long) As Long
    TreeView_GetSelection = TreeView_GetNextItem(hWnd, 0, TVGN_CARET)
    End Function

    TVGN CARET IS DEFINED AS FOLLOWS:

    Public Enum TVM_GETNEXTITEM_wParam
    TVGN_ROOT = &H0
    TVGN_NEXT = &H1
    TVGN_PREVIOUS = &H2
    TVGN_PARENT = &H3
    TVGN_CHILD = &H4
    TVGN_FIRSTVISIBLE = &H5
    TVGN_NEXTVISIBLE = &H6
    TVGN_PREVIOUSVISIBLE = &H7
    TVGN_DROPHILITE = &H8
    TVGN_CARET = &H9
    #If (Win32_IE >= &H400) Then
    TVGN_LASTVISIBLE = &HA
    #End If
    End Enum


    SendMessage is defined as follows (Ansi Version - hence Alias)

    Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    wParam As Any, _
    lParam As Any) As Long

    That enough code for ya?


    BTW - all hNodes are valid, and can be successfully used with other calls
    to do things such embolden a node, or "cut" a node...it's just the SelectItem
    that won't play ball - try TVM_SELECTITEM for yourself, if you can get it
    to work i'll be eternally grateful...thanks again for your time...

  6. #6
    Jonathan Wood Guest

    Re: Treeview Macros / Messages for selecting a node - hItem

    Crispin,

    > That enough code for ya?


    Actually, inclusion of the other declares and functions would have saved me
    a lot of time.

    I entered all the code and it is working for me. I can show you the code I
    used but it's the same as yours. What are you expecting to happen?

    Your code says "select the item that is already selected". And that's what
    it does for me.

    The only oddness I found was that it appeared the current item was being
    unselected. The reason for that was because I had the HideSelection property
    set to True and so the highlight was hidden when I clicked on my button.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com



  7. #7
    Jonathan Wood Guest

    Re: Treeview Macros / Messages for selecting a node - hItem

    Crispin,

    > That enough code for ya?


    Actually, inclusion of the other declares and functions would have saved me
    a lot of time.

    I entered all the code and it is working for me. I can show you the code I
    used but it's the same as yours. What are you expecting to happen?

    Your code says "select the item that is already selected". And that's what
    it does for me.

    The only oddness I found was that it appeared the current item was being
    unselected. The reason for that was because I had the HideSelection property
    set to True and so the highlight was hidden when I clicked on my button.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center