Announcement

Collapse
No announcement yet.

MS TreeView logic..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MS TreeView logic..

    Needed a routine to enumerate visible items in a TreeView. Okay, easy
    task - MS provides macros. First use TreeView_GetFirstVisible and then
    let TreeView_GetNextVisible run in a loop. Simple enough, until one
    encounters MS logic.. (of course the above fails)

    Time to read the docs - for TreeView_GetNextVisible MS says, "The specified
    item must be visible. Use the TVM_GETITEMRECT message to determine whether
    an item is visible". Logic, eh? To use GetNextVisible, we must first make
    sure next item really is visible? Sigh..

    Anyway - following works, in case someone needs it:
    Code:
      hItem = TreeView_GetFirstVisible(hTree)
      WHILE hItem
         IF TreeView_GetItemRect(hTree, hItem, rc, %TRUE) THEN 'make sure it's visible
            ' do stuff
            hItem = TreeView_GetNextVisible(hTree, hItem)     'look for next visible
         END IF
      WEND

    ------------------

  • #2
    Borje,

    I am not sure if Microsoft, Treeview and Logic can be used together
    in the same sentence.

    Nice simple looking piece of code.

    Regards,

    [email protected]

    ------------------
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

    Comment


    • #3
      You are right, guess one can call it "a contradiction in terms"..

      Steve Ballmer is in Sweden right now to sell Win XP. Said that "since
      entire Sweden now has broadband..". I, and all the other 80-85% of all
      Internet connected here that still has to use slow modems understands
      MS logic much better now. Same thing we call "lively fantasy"..

      Another little TreeView snippet, maybe useful to someone:
      Code:
      '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
      ' Count childs under parent item in TreeView
      '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
      FUNCTION tvChildCount(BYVAL hTree AS LONG, BYVAL hParent AS LONG) AS LONG
        LOCAL i AS LONG, hItem AS LONG
       
        hItem = TreeView_GetChild(hTree, hParent)
        WHILE hItem
           hItem = TreeView_GetNextSibling(hTree, hItem)
           INCR i
        WEND
       
        FUNCTION = i
      END FUNCTION

      ------------------

      Comment

      Working...
      X