FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

HowTo: Use lParam within treeview TV_ITEMA node?

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
Lynn



Joined: 27 Aug 2004
Posts: 89

PostPosted: Wed Dec 22, 2004 3:33 pm    Post subject: HowTo: Use lParam within treeview TV_ITEMA node? Reply with quote

I would like to use the lParam field within a TreeView TV_ITEMA node. When creating the TreeNode, I want to set the item.lParam field to be a coded value. (book num * 1000 + chapNum)

Genesis lParam = 1000
.. Gen.1 lParam = 1001
.. Gen.2 lParam = 1002
.. etc.
.. Gen.50 lParam = 1050
Exodus lParam = 2000
.. Exod.1 lParam = 2001
.. Exod.2 lParam = 2002
.. etc.
.. Exod.40 lParam = 2040
etc.

When I select the node, I would like to be able to acquire the lParam value to determine which specific chapter of which book was selected.

Can this be done? Is this what the "tag" field is for?
Back to top
View user's profile Send private message
Lynn



Joined: 27 Aug 2004
Posts: 89

PostPosted: Wed Dec 22, 2004 7:55 pm    Post subject: Reply with quote

Nevermind ...

I was able to utilize the "tag" field and accomplish what I wanted.

Code:

class BookChapTag: Object
{
  int bookNum;
  int chapNum;

  this(int b, int c)
  {
    bookNum = b;
    chapNum = c;
  }
  int book() { return bookNum; }
  int chap() { return chapNum; }
}

for (int bk = 1; bk <= 66; ++bk) {
  char[] bookName = GetBookName(bk);
  bookNode[bk] = new TreeNode(bookName);
  bookNode[bk].tag(new BookChapTag(bk, 0));
  chapSelectorTree.nodes.add(bookNode[bk]);

  int chapCount = GetMaxChapInBook(bk);
  for (int chapNum = 1; chapNum <= chapCount; ++chapNum) {
    char[] chapName = GetBookNameAbbrev(bk) ~ "."
                    ~ std.string.toString(chapNum);
    TreeNode curNode = new TreeNode(chapName);
    curNode.tag(new BookChapTag(bk, chapNum));
    bookNode[bk].nodes.add(curNode);
  }
}

private void OnChapTreeSelect(Object sender, TreeViewEventArgs ea)
{
  Object o = ea.node.tag;
  BookChapTag bct = cast(BookChapTag)o;
  gCurBook = bct.book;
  gCurChap = bct.chap;
  LoadTextViewerWithChapter();
}
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Thu Dec 23, 2004 8:56 am    Post subject: Reply with quote

There's tag, or you can derive from TreeNode:
Code:
class ChapTreeNode: TreeNode
{
   int chapNum;
   this(int chapNum, char[] text)
   {
      super(text);
      this.chapNum = chapNum;
   }
}
...
chapSelectorTree.nodes.add(new ChapTreeNode(1, "foo"));
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group