Load an API Image list from a Strip Bitmap in a resource file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Load an API Image list from a Strip Bitmap in a resource file

  1. #1
    Scott Stanaland Guest

    Load an API Image list from a Strip Bitmap in a resource file

    I am trying to use the ImageList_LoadImage api function to Load a image list
    from a strip bitmap that is in my resource file.

    I use the following code:

    '***************************************************************

    Declare Function ImageList_LoadImage Lib "COMCTL32" Alias
    "ImageList_LoadImageA" (ByVal hi As Long, ByVal lpbmp As String, ByVal cx As
    Long, ByVal cGrow As Long, ByVal crMask As Long, ByVal uType As Long, ByVal
    uFlags As Long) As Long

    m_himl = ImageList_LoadImage(App.hInstance, CStr("#101"), 16, -1, RGB(0,
    128, 128), IMAGE_BITMAP, 0&)

    '***************************************************************

    What am I missing this seems like it should work!!!

    Help

    Scott




  2. #2
    Scott Stanaland Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Ok I figured out that if I compile the program to an EXE the code works
    fine.

    Is there a way to make the code work correctly in the IDE?

    This would be kind of a pain to have to compile to see the images correctly.

    TIA

    Scott

    Scott Stanaland <stanland@bellsouth.net> wrote in message
    news:39352937$1@news.devx.com...
    > I am trying to use the ImageList_LoadImage api function to Load a image

    list
    > from a strip bitmap that is in my resource file.
    >
    > I use the following code:
    >
    > '***************************************************************
    >
    > Declare Function ImageList_LoadImage Lib "COMCTL32" Alias
    > "ImageList_LoadImageA" (ByVal hi As Long, ByVal lpbmp As String, ByVal cx

    As
    > Long, ByVal cGrow As Long, ByVal crMask As Long, ByVal uType As Long,

    ByVal
    > uFlags As Long) As Long
    >
    > m_himl = ImageList_LoadImage(App.hInstance, CStr("#101"), 16, -1, RGB(0,
    > 128, 128), IMAGE_BITMAP, 0&)
    >
    > '***************************************************************
    >
    > What am I missing this seems like it should work!!!
    >
    > Help
    >
    > Scott
    >
    >
    >




  3. #3
    Scott Stanaland Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Ok I figured out that if I compile the program to an EXE the code works
    fine.

    Is there a way to make the code work correctly in the IDE?

    This would be kind of a pain to have to compile to see the images correctly.

    TIA

    Scott

    Scott Stanaland <stanland@bellsouth.net> wrote in message
    news:39352937$1@news.devx.com...
    > I am trying to use the ImageList_LoadImage api function to Load a image

    list
    > from a strip bitmap that is in my resource file.
    >
    > I use the following code:
    >
    > '***************************************************************
    >
    > Declare Function ImageList_LoadImage Lib "COMCTL32" Alias
    > "ImageList_LoadImageA" (ByVal hi As Long, ByVal lpbmp As String, ByVal cx

    As
    > Long, ByVal cGrow As Long, ByVal crMask As Long, ByVal uType As Long,

    ByVal
    > uFlags As Long) As Long
    >
    > m_himl = ImageList_LoadImage(App.hInstance, CStr("#101"), 16, -1, RGB(0,
    > 128, 128), IMAGE_BITMAP, 0&)
    >
    > '***************************************************************
    >
    > What am I missing this seems like it should work!!!
    >
    > Help
    >
    > Scott
    >
    >
    >




  4. #4
    Mattias Sjögren Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Scott,

    >I am trying to use the ImageList_LoadImage api function to Load a image list
    >from a strip bitmap that is in my resource file.


    Are you running in the IDE or compiled code? APIs dealing with
    resources wont work in the IDE, because App.hInstance points to the
    VB6.EXE instead of your app. When you compile the code it should work.

    Another thing you could try is to change the declare to
    ...., ByVal lpbmp As Long, ...
    and call it with ImageList_LoadImage(..., 101, ...)
    Not that it should matter, but you never know :-)

    One last thing. I see you're passing -1 as the cGrow parameter. I
    can't see anything in the docs about using -1 there. So why do you do
    that, and have you tried changing it to xero or some positive value?


    Mattias

    ____________________________________________
    Mattias Sjögren - mattiass @ hem.passagen.se
    http://hem.spray.se/mattias.sjogren/

  5. #5
    Mattias Sjögren Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Scott,

    >I am trying to use the ImageList_LoadImage api function to Load a image list
    >from a strip bitmap that is in my resource file.


    Are you running in the IDE or compiled code? APIs dealing with
    resources wont work in the IDE, because App.hInstance points to the
    VB6.EXE instead of your app. When you compile the code it should work.

    Another thing you could try is to change the declare to
    ...., ByVal lpbmp As Long, ...
    and call it with ImageList_LoadImage(..., 101, ...)
    Not that it should matter, but you never know :-)

    One last thing. I see you're passing -1 as the cGrow parameter. I
    can't see anything in the docs about using -1 there. So why do you do
    that, and have you tried changing it to xero or some positive value?


    Mattias

    ____________________________________________
    Mattias Sjögren - mattiass @ hem.passagen.se
    http://hem.spray.se/mattias.sjogren/

  6. #6
    Mattias Sjögren Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Scott,

    >Is there a way to make the code work correctly in the IDE?


    Probably not using ImageList_LoadImage. But you could use VBs
    LoadResPicture function (which does work in the IDE), and then put the
    returned bitmap in an ImageList using ImageList_AddMasked.

    The code would look something like this (not tested though):

    m_himl = ImageList_Create(...)
    Call ImageList_AddMasked(m_himl, LoadResPicture(101,
    vbResBitmap).Handle, RGB(0, 128, 128))


    Mattias

    ____________________________________________
    Mattias Sjögren - mattiass @ hem.passagen.se

  7. #7
    Mattias Sjögren Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Scott,

    >Is there a way to make the code work correctly in the IDE?


    Probably not using ImageList_LoadImage. But you could use VBs
    LoadResPicture function (which does work in the IDE), and then put the
    returned bitmap in an ImageList using ImageList_AddMasked.

    The code would look something like this (not tested though):

    m_himl = ImageList_Create(...)
    Call ImageList_AddMasked(m_himl, LoadResPicture(101,
    vbResBitmap).Handle, RGB(0, 128, 128))


    Mattias

    ____________________________________________
    Mattias Sjögren - mattiass @ hem.passagen.se

  8. #8
    Scott Stanaland Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Mattias

    The ImageList_AddMasked Funtion worked well!

    Thanks alot for the help!!

    Scott

    Mattias Sjögren <mattiass.dont.want.spam@hem.passagen.se> wrote in message
    news:39353034.3403814@news.devx.com...
    > Scott,
    >
    > >Is there a way to make the code work correctly in the IDE?

    >
    > Probably not using ImageList_LoadImage. But you could use VBs
    > LoadResPicture function (which does work in the IDE), and then put the
    > returned bitmap in an ImageList using ImageList_AddMasked.
    >
    > The code would look something like this (not tested though):
    >
    > m_himl = ImageList_Create(...)
    > Call ImageList_AddMasked(m_himl, LoadResPicture(101,
    > vbResBitmap).Handle, RGB(0, 128, 128))
    >
    >
    > Mattias
    >
    > ____________________________________________
    > Mattias Sjögren - mattiass @ hem.passagen.se




  9. #9
    Scott Stanaland Guest

    Re: Load an API Image list from a Strip Bitmap in a resource file

    Mattias

    The ImageList_AddMasked Funtion worked well!

    Thanks alot for the help!!

    Scott

    Mattias Sjögren <mattiass.dont.want.spam@hem.passagen.se> wrote in message
    news:39353034.3403814@news.devx.com...
    > Scott,
    >
    > >Is there a way to make the code work correctly in the IDE?

    >
    > Probably not using ImageList_LoadImage. But you could use VBs
    > LoadResPicture function (which does work in the IDE), and then put the
    > returned bitmap in an ImageList using ImageList_AddMasked.
    >
    > The code would look something like this (not tested though):
    >
    > m_himl = ImageList_Create(...)
    > Call ImageList_AddMasked(m_himl, LoadResPicture(101,
    > vbResBitmap).Handle, RGB(0, 128, 128))
    >
    >
    > Mattias
    >
    > ____________________________________________
    > Mattias Sjögren - mattiass @ hem.passagen.se




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center