Joe,

 

A method I have used for this situation is to store the nodes of the treeview 
in a hash when populating the treeview, like this:

 

my %Nodes;

my $treeview = Win32::GUI::TreeView->new(

 -name => 'TreeView',

 #...

);

foreach(1..9){

 my $node = $treeview->InsertItem(-text => $_);

 $Nodes{$node} = $_;

 # More information about each element could also be stored in the hash

}

 

__END__

 

A treeview node is simply a number, which makes it simple to store and fetch 
from a hash.

 

Then, you can set up a callback for the Expand or Expanding event. The 
Expanding event is called just before the node is expanded and can be used to 
prevent it by returning 0. You can use this event if you need it; otherwise use 
the Expand event. The callback is passed a parameter specifying which node is 
being expanded, which can be used to look up the element in the hash created 
above, like this:

 

sub TreeView_Expand {

 my $node = shift;

 my $element = $Nodes{$node};

 my %item = $TreeView->GetItem($node);

 # Do other processing here

}

 

__END__

 

I have used this method to display information in a listview when a node is 
selected in the treeview. I simply stored the data I wanted displayed in the 
hash of nodes and then displayed the data in the listview when a treeview node 
was clicked.

 

Hope this helps,

 

Kevin.
 
> From: joe.mo...@siemens.com
> To: perl-win32-gui-users@lists.sourceforge.net
> Date: Mon, 12 Apr 2010 13:36:52 -0400
> Subject: [perl-win32-gui-users] Getting the node that's being Expanded in a 
> TreeView
> 
> Hi, I'm trying to find out which element of a TreeView is being expanded when 
> someone clicks on the "+" beside it.
> 
> The TreeView is generated dynamically from a list of lists, eg:
> ( 1, 2, [ 3, 4 ], 5, [ 6, [7]] )
> yields a tree of
> - 1
> - 2
> - 3
> - 4
> - 5
> - 6
> - 7
> 
> I've tried with the $node_Expand and $node_Expanding callbacks to identify 
> which of the child nodes is being expanded, but I haven't been able to chase 
> down who is expanding.
> 
> Do I need to define a $node_Expand callback for each of the numbered nodes? 
> Or am I missing something obvious?
> 
> (Using ActiveState Perl 5.10.1 with their Win32::GUI 1.06 from PPM)
> 
> --Joe
> 
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
                                          
_________________________________________________________________
If It Exists, You'll Find it on SEEK. Australia's #1 job site
http://clk.atdmt.com/NMN/go/157639755/direct/01/
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to