Results 1 to 8 of 8

Thread: [RESOLVED] Draw to an icon?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    291

    Resolved [RESOLVED] Draw to an icon?

    How can I draw something to an icon? I am unable to get the graphics from an icon, so that I can use the DrawLine procedures etc.

    I really want to know this. And it needs to be done in-memory, and should not use files to store the icons.

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

    Re: Draw to an icon?

    so you want to grab an existing icon file, do something with it like draw a line on it?

    And then what? You said it should not store the icon as a file, so what exactly do you want to do? grab an icon, draw on it, and then use it in the application?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    291

    Re: Draw to an icon?

    Wow! You are the main administrator of VBForums! Cool!

    Anyway, back to subject.


    After loading the icon as a variable, manipulating it by drawing a line on it (or anything else), I would like to display it as the icon in a NotifyIcon control.

  4. #4
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Draw to an icon?

    Hi,

    First of all, grap someone else created icon is in my opion not a good idee, however create your own would be must better. There are many programs where you can create icons.
    Then you can create a notifyicon here.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    291

    Re: Draw to an icon?

    I need to be able to draw to the icon. I want the icon to show a number telling the user how many items there are available in a listbox.

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Draw to an icon?

    I believe you'd have to do something like this:

    Code:
            Dim myIcon As Icon = New Icon("F:\windows\mic.ico")
            Dim myIconBitmap As Bitmap = myIcon.ToBitmap()
    
            Using g As Graphics = Graphics.FromImage(myIconBitmap)
                g.FillRectangle(Brushes.Red, New Rectangle(0, 0, 10, 10))
            End Using
    
            myIcon.Dispose()
            myIcon = Icon.FromHandle(myIconBitmap.GetHicon())
            myIconBitmap.Dispose()
            myNotifyIcon.Icon = myIcon
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  7. #7
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Draw to an icon?

    Hi,

    Add a notifyicon to your application and select in the properties wich icon you need. Then change the text with the Listbox.objectcollection.count property to draw the totale of items there are in the listbox.

    Something like this:

    vb Code:
    1. Dim filecount As Integer
    2.   filecount = ListBox1.Items.Count
    3.   filecount += 1
    4. Notifyicon1.Text = filecount
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Denmark
    Posts
    291

    Re: Draw to an icon?

    Sparrow thanks, but that's not what I need. Atheist provided the correct solution. THANKS ATHEIST!

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