• ImageList_GetImageInfo - alter the bitmap(s) ?

    From R.Wieser@21:1/5 to All on Mon Sep 30 21:11:50 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    Hello all,

    Using XPsp3.

    I was playing with the idea to dynamically alter the contents of an
    ImageList, and found the https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_getimageinfo
    function, which says :

    "The information in this structure can be used to *directly* manipulate the bitmaps for the image"

    (bolding mine).

    I've been trying to think of how that is possible - the bitmaps cannot be selected into a memoryDC - and to google information about how that would
    work, but came up empty.

    Question:
    Does anyone know what "directly manipulate the bitmaps" method MS is
    referring to in the above ?

    Remark:
    I already thought of and written another way to do what I want, but would
    like to know how the above works. Who knows, their (MS) method might be simpler. :-)

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Newyana2@21:1/5 to R.Wieser on Mon Sep 30 15:41:57 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    On 9/30/2024 3:11 PM, R.Wieser wrote:
    Hello all,

    Using XPsp3.

    I was playing with the idea to dynamically alter the contents of an ImageList, and found the https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_getimageinfo
    function, which says :

    "The information in this structure can be used to *directly* manipulate the bitmaps for the image"

    (bolding mine).

    I've been trying to think of how that is possible - the bitmaps cannot be selected into a memoryDC - and to google information about how that would work, but came up empty.

    Question:
    Does anyone know what "directly manipulate the bitmaps" method MS is referring to in the above ?

    Remark:
    I already thought of and written another way to do what I want, but would like to know how the above works. Who knows, their (MS) method might be simpler. :-)


    I've never used an ImageList, but the docs say GetImageInfo returns
    an ImageInfo structure, which includes an hBitmap. With that you can
    call things like GetDIBits, SetDIBits, etc.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Tue Oct 1 09:02:57 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    Newyana2,

    but the docs say GetImageInfo returns an ImageInfo structure, which
    includes an hBitmap.

    Indeed it does. Having the bitmap(s) is where my problems started. :-\

    With that you can call things like GetDIBits, SetDIBits, etc.

    Yep, I found the first one too (as well as GetBitmapBits). But I realized
    that it takes a *lot* of work to be able to create something generic from it (for instance, it would need handlers for all 6 BPP modi).

    Also SetDIBits needs a BITMAPINFO structure filled in with stuff I /somehow/ would need to extract/copy from the origional bitmap.

    The easier way (I think) would be to use CopyBitmap, load it into a
    memoryDC* and use that to make the alterations on.

    * which I would need to make sure it would have the same configuration
    (Image List Creation Flags) as the one the ImageList was created with. In short: another problem.

    ... but that than has a "how do I get it back into the origional bitmap/imagelist ?" problem.

    I was hoping that the MS way would show me a simple, smart way to circumvent all that clumsy work.

    By the way:
    for one test approach I invoked "the dark arts" and retrieved the
    memoryDC(s) the ImageList uses internally. Drawing on them works as
    expected, very easy. Though there are a number of gotya's to recon with. As well as the use of "the dark arts" ofcourse. :-)

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Newyana2@21:1/5 to R.Wieser on Tue Oct 1 10:37:57 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    On 10/1/2024 3:02 AM, R.Wieser wrote:
    Newyana2,

    but the docs say GetImageInfo returns an ImageInfo structure, which
    includes an hBitmap.

    Indeed it does. Having the bitmap(s) is where my problems started. :-\

    With that you can call things like GetDIBits, SetDIBits, etc.

    Yep, I found the first one too (as well as GetBitmapBits). But I realized that it takes a *lot* of work to be able to create something generic from it (for instance, it would need handlers for all 6 BPP modi).

    Also SetDIBits needs a BITMAPINFO structure filled in with stuff I /somehow/ would need to extract/copy from the origional bitmap.

    The easier way (I think) would be to use CopyBitmap, load it into a
    memoryDC* and use that to make the alterations on.

    * which I would need to make sure it would have the same configuration
    (Image List Creation Flags) as the one the ImageList was created with. In short: another problem.

    ... but that than has a "how do I get it back into the origional bitmap/imagelist ?" problem.

    I was hoping that the MS way would show me a simple, smart way to circumvent all that clumsy work.

    By the way:
    for one test approach I invoked "the dark arts" and retrieved the
    memoryDC(s) the ImageList uses internally. Drawing on them works as expected, very easy. Though there are a number of gotya's to recon with. As well as the use of "the dark arts" ofcourse. :-)


    That stuff is something I have to figure out anew every time I
    work with it. I once wrote a program for my girlfriend to easily
    do auto-cropping and resizing of photos in high quality. The image
    ops were so complicated that I used a class to load images, convert
    to DIB, then do operations on that. GDI gets very complicated.
    Gdiplus is worse.

    Recently I've been working on functionality to change caret width
    and color in a text window. The way to do it is to use a bitmap. So
    I needed to be able to generate an endless variety of bitmaps
    "on the fly". It took awhile to refresh my memory about hbitmaps and
    DCs and such. But in VB6 there's the Picturebox control. Lightweight
    and it wraps a lot of GDI ops. It turned out that I could paint the caret
    in a hidden picturebox, then pass that picture's handle to the caret
    function because a picture in a picturebox is a StdPicture. Maybe you
    have something like that with Borland?

    In terms of imaglists, I have no idea. I've never had occasion to
    use one. I sometimes use Image controls and sometimes use resources,
    but never an imagelist.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Tue Oct 1 19:11:02 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    Newyana2,

    GDI gets very complicated. Gdiplus is worse.

    I've used both, but have not tried anything complicated with it.

    Recently I've been working on functionality to change caret width
    and color in a text window. The way to do it is to use a bitmap.

    That makes me remember something ..Oh yes, there it is. Maybe its useful to you :

    https://devblogs.microsoft.com/oldnewthing/20240916-00/?p=110272

    But in VB6 there's the Picturebox control. Lightweight
    and it wraps a lot of GDI ops.
    ...
    Maybe you have something like that with Borland?

    :-) Thats the nice thing of using an Assembler : No programming-language provided wrappers around anything, you have to (understand and) write all of them yourself.

    ... which is also its downside.

    But with me being me I normally have little problem with that. Even though that leads to problems as my current one.

    I sometimes use Image controls and sometimes use resources,
    but never an imagelist.

    If you have ever used a List- or TreeView showing icons (including sorting-direction arrows and tickboxes) than you have used an ImageList.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Newyana2@21:1/5 to R.Wieser on Tue Oct 1 20:12:25 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    On 10/1/2024 1:11 PM, R.Wieser wrote:

    That makes me remember something ..Oh yes, there it is. Maybe its useful to you :

    https://devblogs.microsoft.com/oldnewthing/20240916-00/?p=110272

    Even Raymond Chen has opted for totally fucked up web design.
    His page is pure white for me unless I disable CSS. He must be tryint
    to force script.


    If you have ever used a List- or TreeView showing icons (including sorting-direction arrows and tickboxes) than you have used an ImageList.

    Nope. I've never needed those and they seem like a pain.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Oct 2 09:08:40 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    Newyana2,

    Even Raymond Chen has opted for totally fucked up web design.
    His page is pure white for me unless I disable CSS.

    Ah yes, I forgot about that. I scrubbed that page (like many others) using GreaseMonkey. A quite handy add-on.

    He must be tryint to force script.

    He ? devblogs.microsoft.com isn't his private domain you know. :-)

    But yes, JS could have something to do with it - as I have disabled it too.

    If you have ever used a List- or TreeView showing icons (including
    sorting-direction arrows and tickboxes) than you have used an ImageList.

    Nope. I've never needed those and they seem like a pain.

    List- and/or TreeViews, or images in them ?

    I can't say I've used TreeViews much, but have used ListViews a number of times, and some of them with ImageLists.

    Images in in either a List- or TreeView is easier than you might think.
    Just create an ImageList and assign it to the View, load some images/icons
    into it, and tell, when adding an entry into either View, which image you
    want to display. Thats all there is to it.

    But yes, it took me a while until I had/have everything figured out. Thats what happens when most of what you find is "learn.microsoft.com" pages
    (which mostly do not /learn/ you anything, but are "what again where the arguments to that function?" reference pages - and often incomplete. As the one I started this thread with) and the odd bits-and-pieces of "example"
    code I can find on the Web.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kerr-Mudd, John@21:1/5 to R.Wieser on Wed Oct 2 17:07:34 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    On Tue, 1 Oct 2024 19:11:02 +0200
    "R.Wieser" <[email protected]d> wrote:

    Newyana2,

    GDI gets very complicated. Gdiplus is worse.

    I've used both, but have not tried anything complicated with it.

    Recently I've been working on functionality to change caret width
    and color in a text window. The way to do it is to use a bitmap.

    That makes me remember something ..Oh yes, there it is. Maybe its useful to you :

    https://devblogs.microsoft.com/oldnewthing/20240916-00/?p=110272

    But in VB6 there's the Picturebox control. Lightweight
    and it wraps a lot of GDI ops.
    ...
    Maybe you have something like that with Borland?

    :-) Thats the nice thing of using an Assembler : No programming-language provided wrappers around anything, you have to (understand and) write all of them yourself.

    Unless you use libraries aznd function calls extensively.

    ... which is also its downside.

    But with me being me I normally have little problem with that. Even though that leads to problems as my current one.

    I sometimes use Image controls and sometimes use resources,
    but never an imagelist.

    If you have ever used a List- or TreeView showing icons (including sorting-direction arrows and tickboxes) than you have used an ImageList.

    Regards,
    Rudy Wieser




    --
    Bah, and indeed Humbug.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Oct 2 18:55:41 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    John,

    No programming-language provided wrappers around anything,
    you have to (understand and) write all of them yourself.

    Unless you use libraries aznd function calls extensively.

    And thats indeed what I do. :-)

    I *have* to, as, as mentioned, my programming language of choice, Assembly (Borlands Tasm32), doesn't offer such wrappers.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Newyana2@21:1/5 to R.Wieser on Wed Oct 2 13:28:17 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    On 10/2/2024 12:55 PM, R.Wieser wrote:
    John,

    No programming-language provided wrappers around anything,
    you have to (understand and) write all of them yourself.

    Unless you use libraries aznd function calls extensively.

    And thats indeed what I do. :-)

    I *have* to, as, as mentioned, my programming language of choice, Assembly (Borlands Tasm32), doesn't offer such wrappers.


    I bought the assembly bible once and started reading. I decided
    life's too short for that. The beauty of VB6 is that I can drag-drop
    GUI elements. No 3 pages of code to create a button. At the same
    time, I can use Win32 API for most of the functionality. I probably
    never would have bothered if the only choice were early C++. If I
    want to write that doesn't mean I also want to perfect paper
    manufacturing. I can see the appeal of building a ship in a
    bottle. I'm just too practical to do all that work only to have an
    object to sit on a bookshelf.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Oct 2 21:47:52 2024
    XPost: alt.windows7.general, comp.os.ms-windows.programmer.win32

    Newyana2,

    I bought the assembly bible once and started reading. I decided
    life's too short for that.

    :-)

    I pretty-much started with Assembly and worked my way thru a number of home computers (TRS80, Apple 2e, commodore 64) to arrive at the X86 machines, starting with DOS 3.3, where I started to use borlands assembler(s). Later
    on I bought Borlands Tasm32

    Although I've tried a few other programming languages, somehow I always returned to Assembly.

    The beauty of VB6 is that I can drag-drop GUI elements. No 3 pages of code
    to create a button.

    Ah, that. Yes, I started with that too. But when I discovered Dialogs and
    how I could add a button (or any other control) with just a single line in a resource file I dropped the whole CreateWindowEx and all of that approach,
    and used DialogBoxParam instead.

    I can see the appeal of building a ship in a bottle. I'm just too
    practical to do all that work only to have an object to sit on a
    bookshelf.

    :-) My interrest is mosty towards figuring out how to get stuff working.
    As a result I have a lot of "how does this work" test programs, which I
    often abandon when I have a clear view of the harbour.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)