From: Robert M. <rob...@us...> - 2007-06-26 20:32:50
|
On 22/06/07, Salvador Ortiz Garc=EDa <so...@ms...> wrote: > Hi all, > > This is my first post to the list, so forgive me if this was discussed > before. I don't think it has been discussed before, but I have noticed it myself. I didn't find it enough of an issue to want to deal with it. > > Reflecting the Win32 API, Win32::GUI::TreeView has a GetParent method to > get the parent node (HTREEITEM) of a node, nothing related with the > GetParent common method of Win32::GUI. > > The common call > > my $parentWin =3D $SomeControl->GetParent(); > > simply don't work when $SomeContros isa TreeView, so right now when I > need the parent window of the TV control we must use an ugly workaround: > > my $parentWin =3D Win32::GUI::GetParent($TreeView); > > The following patch cures that, properly subclassing the TreeView with > only minimal semantic changes IMHO: > > When called without NODE or with NODE equal zero (NULL, an invalid > HTREEITEM value anyway) now TreeView::GetParent() returns the parent > window, if any, or undef as Win32::GUI::GetParent() does. > > Any other value for NODE returns the handler of the parent NODE (or NULL > at the root NODE) as documented. > > So the following works as spected: > > sub TV_NodeClick { # Click on a node, OEM form > my($TreeView, $node) =3D @_; > my $parentWin =3D $TreeView->GetParent(); > my $parentNode =3D $TreeView->GetParent($node); > ... > > Comments? I'm a bit short of time at the moment, but I'd like to give this some more though, as one of the things I strive for is backwards compatibility and I'm not completely convinced. I think the idea is OK, but I'd like to tinker with the implementation a little ... give me a couple of weeks to mull it over. Many thanks for the contribution. Regards, Rob. > > =3D=3D=3D=3D=3D=3D=3D=3D=3D CUT =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- Win32-GUI/TreeView.xs 2006-04-13 17:17:07.000000000 -0500 > +++ /home/sog/dosdir/work/Win32-GUI-1.05_01/TreeView.xs 2007-06-22 > 00:59:20.000000000 -0500 > @@ -583,15 +583,32 @@ > > > #########################################################################= ## # (@)METHOD:GetParent(NODE) > - # Returns the handle of the parent node for the given B<NODE>. > -HTREEITEM > -GetParent(handle,item) > + # Returns the handle of the parent node for the B<NODE>, if given > + # or the parent window of the TV control if not. > +void > +GetParent(handle,item =3D 0) > HWND handle > HTREEITEM item > -CODE: > - RETVAL =3D TreeView_GetParent(handle, item); > -OUTPUT: > - RETVAL > +PREINIT: > + HWND parentHandle; > + SV* SvParent; > +PPCODE: > + if (item) { > + XSRETURN_IV((long) TreeView_GetParent(handle, item)); > + } else { > + parentHandle =3D GetParent(handle); > + if (parentHandle !=3D NULL) { > + SvParent =3D SV_SELF_FROM_WINDOW(parentHandle); > + if (SvParent !=3D NULL && SvROK(SvParent)) { > + XPUSHs(SvParent); > + } else { > + XSRETURN_UNDEF; > + } > + } else { > + XSRETURN_UNDEF; > + } > + } > + > > > #########################################################################= ## # (@)METHOD:GetPrevSibling(NODE) > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CUT =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > > Bests Regards. > > -- > Salvador Ortiz. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Perl-Win32-GUI-Hackers mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-hackers > http://perl-win32-gui.sourceforge.net/ > --=20 Please update your address book with my new email address: ro...@th... |