Results 1 to 12 of 12

Thread: Dynamic icons?

  1. #1

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Dynamic icons?

    Is it possible to create an icon image at runtime?

    I want to be able to draw a small image through code and then convert it to an icon class.

    I do not want to load any icons from disc, nor save them to disc. the data must reside in RAM only. I notice that Icon has a ToBitmap() method, but I can find no similar method to reverse that conversion.
    I don't live here any more.

  2. #2

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Dynamic icons?

    Quote Originally Posted by kulrom
    Hi,
    just load an image into a bitmap object and use the bitmap.toicon()
    method...there's also a method to save that resulting image to file.
    Regards
    That's what I wanted to do but, apparently, bitmap.toIcon() doesn't exist. Not in VS 2003 anyway, what version are you using?
    I don't live here any more.

  3. #3
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Dynamic icons?

    Quote Originally Posted by kulrom
    Oh i've forgoten to point out that method comes from vb6

    btw, you might not be able to do that ...
    hmmm ... but maybe you just need to get the graphical handle of the object ( sound of wisdom )

    i.e.
    assuming bmp is a variable for your bitmap...
    VB Code:
    1. Dim ico As Icon = Icon.FromHandle(bmp.GetHicon())
    that might work
    did you search google for that?

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Dynamic icons?

    Quote Originally Posted by kulrom
    yes for the toicon method ... is that something wrong?
    do you have a solution? probably you don't! then why you are asking sucha QUESTION?
    just wondering because i searched convert bitmap to icon and that was the exact code from the first result...

    I use google all the time to find answers, so I was just wondering if you had done the same

  5. #5

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Dynamic icons?

    Quote Originally Posted by kulrom
    yes for the toicon method ... is that something wrong?
    do you have a solution? probably you don't! then why you are asking sucha QUESTION?
    That's a bit cocky for a guy that first suggests something from an obsolete language, and then something that doesn't work.

    The bmp.GetHIcon method just yields a black square rather than the icon in question. It does compile and run though.

    The bitmap is holding the icon properly but I can't convert it to an icon.

    This is so irritating.
    I don't live here any more.

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Dynamic icons?

    no I think you took it wrong, I was just wondering... why would there be anything wrong with searching google to give someone an answer? Other than the fact that maybe they could have done it themselves...

  7. #7

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Dynamic icons?

    Another thread rages off topic.
    I don't live here any more.

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Dynamic icons?

    sorry woss... what size images are you trying to convert to icons? is it set? or could it be any size image that would need to be converted.. also are you looking to make just a single size icon? or one that supports multiple size, like 16x16,32x32, etc...

  9. #9

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Dynamic icons?

    Quote Originally Posted by kleinma
    sorry woss... what size images are you trying to convert to icons? is it set? or could it be any size image that would need to be converted.. also are you looking to make just a single size icon? or one that supports multiple size, like 16x16,32x32, etc...
    I'm trying to animate an icon that will be shown in a NotifyIcon object on the taskbar.

    I want to be able to draw things onto a 16x16 bitmap (using the Graphics object) and then convert that to an Icon that can be sent to the NotifyIcon.
    The images always stay in memory, they never get saved or loaded from disc.

    Sounds simple really but its a harder task than it sounds.

    Before you say it I can't use a bunch of icons like a flip-book because each frame will be randomly generated by an algorithm.
    I don't live here any more.

  10. #10
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Re: Dynamic icons?

    Hey Wossy.
    This seems to work just fine.

    VB Code:
    1. Dim b As New Bitmap(16, 16, Imaging.PixelFormat.Format32bppArgb)
    2.  
    3. 'Some drawing here
    4.  
    5. Me.Icon = Icon.FromHandle(b.GetHicon)
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  11. #11

    Thread Starter
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Dynamic icons?

    Strange. What OS are you on? It works on my home laptop with XP on it, but not on my 2000 work PC.

    Maybe something to do with alpha channels.
    I don't live here any more.

  12. #12
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840

    Re: Dynamic icons?

    Hi.

    I used XP.
    Try and make the bitmap 24bit instead.
    Win2000 doesn't support alpha channel in icons.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width