Initialize imagelist?

Discussion in 'SolidWorks' started by What-a-Tool, Oct 22, 2004.

  1. What-a-Tool

    What-a-Tool Guest

    Have images stored in an imagelist that I want to place in a treeview
    control.
    Keep getting the message "Image list must be initialized"

    Can anyone direct me to a code sample of this?
    Can't seem to find anything. I have already added the images that I want
    thru the "custom properties" property window.

    Right now, what I have is :

    With tvwMain
    Set .ImageList = Me.ilstMain '(also tried Me.ilstMain.ListImages)
    tn = .Add(,, strDefPath, strDefFolNm, 1, 2)
    End With

    This causes an error: "Type Mismatch"
    If I remove the "Set", it will make it thru the ".ImageList =" line, but
    when I reach the ".Add" line I get the error : "ImageList must be
    initialized"

    I am using Microsoft ImageList Control 6.0 (SP4) and have a Reference to
    Microsoft Windows Common Controls 6.0 (SP4), and am not using Option
    Explicit.

    Is there some sort of issue with SW and this image list? I've been going
    nuts with this, and can't get it to work no matter what I try.

    Thanks for any help.

    --

    / Sean the Mc /


    "I have not failed. I've just found 10,000 ways that won't work."
    - Thomas Alva Edison (1847-1931)
     
    What-a-Tool, Oct 22, 2004
    #1
  2. What-a-Tool

    Heikki Leivo Guest

    Hello Sean,
    In my code I do the following to initialize the imagelist:

    With myForm.myImageList.ListImages
    .Add Picture:=LoadResPicture("xxx", vbResBitmap), Key:= "foo"
    .Add Picture:=LoadResPicture("yyy", vbResBitmap), Key:= "bar"
    'Add further images from the resource
    End With

    Finally I assign the imagelist to the treeview:

    With myForm.myTreeView
    Set .ImageList = myForm.myImageList
    'define other settings
    ...
    End With

    Hope this helps!

    -h-
     
    Heikki Leivo, Oct 23, 2004
    #2
  3. What-a-Tool

    What-a-Tool Guest

    I'm obviously missing some references, as "LoadResPicture", and
    "vbResBitmap" don't show up in intellisence or help, and give me an
    "unrecognised sub or function error". I've tried different references
    looking for the correct one until my face turned purple.

    Can anyone tell me which (If any ) references I'm missing?

    --

    / Sean the Mc /


    "I have not failed. I've just found 10,000 ways that won't work."
    - Thomas Alva Edison (1847-1931)
     
    What-a-Tool, Oct 25, 2004
    #3
  4. What-a-Tool

    Heikki Leivo Guest

    I'm obviously missing some references, as "LoadResPicture", and
    You are indeed missing something... LoadResPicture is member of VB6 and
    vbResBitmap is a member of VisualBasic Runtime, but at least I don't know
    how (and why) one should _remove_ tehese from their references. You should
    have "Visual basic runtime objects" and "Visual basic objects and
    procedures" checked, but I think you should not be able to uncheck them from
    your references. Are you using Visual Basic 6?

    -h-
     
    Heikki Leivo, Oct 26, 2004
    #4
  5. What-a-Tool

    Heikki Leivo Guest

    have "Visual basic runtime objects" and "Visual basic objects and
    Now I see, you are writing a SW macro, aren't you? There is no sense in
    using resource functions in a macro. My code was just an example, I used the
    functions to initialize the imagelist but but they are not required for the
    code to work.

    -h-
     
    Heikki Leivo, Oct 26, 2004
    #5
  6. What-a-Tool

    What-a-Tool Guest

    Thanks for the help. - Still driving me nuts with "Type Mismatch " and
    Object errors. Never had a headache like this with any other control before.
    I'll get it figured out though (I Hope!)

    Thanks for the help, again.

    --

    / Sean the Mc /


    "I have not failed. I've just found 10,000 ways that won't work."
    - Thomas Alva Edison (1847-1931)
     
    What-a-Tool, Oct 26, 2004
    #6
  7. What-a-Tool

    What-a-Tool Guest

    Ha - Got it figured out - I'm only half as dumb as I was starting to think!

    Had to code in an API call to "mscomctl.ocx". SW must not have the licenses
    to these controls?

    Drove me nuts - the objects were all there for me, just that nothing worked
    the way it was supposed to!

    Thanks for the help

    --

    / Sean the Mc /


    "I have not failed. I've just found 10,000 ways that won't work."
    - Thomas Alva Edison (1847-1931)
     
    What-a-Tool, Oct 27, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.