Yah, I saw those, but thought the other solution would be sufficient ;-) Also, I saw the ICON one which I was not able to track down in the time I allowed my self.

Ok, this one was actually pretty easy to track down.

Now, since it sounds like you will be doing quite a bit with win32 stuff I thought I'd take some time to go through the process I used in tracking these types of things down in the hopes that it will be of more help to you in the long run.
You know, the "Tech'em to fish rather than Feed'em a fish" thing :-)

I'm hungry, just gimme da fish!

Ok, so here's the answer: Use a '0'(zero) as the type parameter.

$tv->SetImageList($il, 0); # Use Flag TVSIL_NORMAL for MS TreeView_Set +ImageList()
The Flag TVSIL_NORMAL Indicates the normal image list, which contains selected, nonselected, and overlay images for the items of a tree-view control. You can read more on it here: TreeView_SetImageList

How do ya catch'em

When using something like the Win32:GUI module and something does not work right, the first thing I do is just blame it on Microsoft ;-)

No, really I'm not joking, their APIs often have lots of parameters/options which interact with each other in sometimes less than obvious ways sometimes depending on values in other parameters witin the API call. I'm not bashing MS, this is just the way it is, IMHO. So, to resolve these problems you have to dig into the MS Docs and check the parms!
In order to do this, however, you have to track down each MS API call being made.

So, in this case I just started with the method that worked, per your example and walked through it.

Starting with  my $tv = $main->AddTreeView, go into GUI.pm and look within the TreeView package and you'll see that is really just calls new, which ends up in GUI.xs as _new with a parm of "WIN32__GUI__TREEVIEW". Then in GUI.xs this is used in a switch statement which leads to a section where the constructor options are processed. Looking a little deeper is seems that the "-imagelist" parameter is just saved off into a 'C' structure tagPERLWIN32GUI_CREATESTRUCT. So, this appears to be uninteresting for our purposes, it is a dead-end.

Moving on to the problem call $tv->SetImageList($il, 24);: Look for it in GUI.pm and you'll see that it does not exist. OK fine, check for it GUI.xs and you'll see there are several Methods by that name, so be sure to find the one in the TreeView package.

MODULE = Win32::GUI PACKAGE = Win32::GUI::TreeView ... METHOD:SetImageList(IMAGELIST, [TYPE]) ... RETVAL = TreeView_SetImageList(handle, imagelist, type);

Finally, we come to where the MS API is called, TreeView_SetImageList().

Look this API call up in the MS Docs (MSDN) and you'll read that type controls the interpretation of imagelist. The options are TVSIL_NORMAL, TVSIL_STATE; and NORMAL sounds like the one for our needs. So, I look it up in the include files to get its value of '0' (zero).

So, the lesson here is (as in the previous example) when using MS APIs in particular, ALWAYS check out those dang parameters ;-}

Finally, the Caveats

Please keep in mind that the break down above is only meant to be helpful, NOT to be preachy or anything else; I know i hate being preached to. Also, there are certainly other ways to go about finding the answer. And most definitly there are better ways to explain it that how I did above. Also, I may have ommitted something along the way. ;-)

ANYHOW, I sincerely hope this helps.


In reply to Re: Re4: (post-create image list) Win32::GUI::TreeView and bitmap masks by knexus
in thread Win32::GUI::TreeView and bitmap masks by bbfu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.