Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello community,

I'm a newcomer in this forum.
I've been programming vb6 for a while now.

I want to draw forms' icons during runtime (that icon which appears on the taskbar button as well as on the title bar of the form).
I've been googling for a while now, but can't come close to a solution.
As far as I understand an icon can persist of a variety of 16x16, 32x32 ... pictures.
How can I use a picture - drawn in runtime - as my icon?
What would be the color of transparency?

Has anybody a clue how to solve my problem?

Thanx 1,000,000

Charlie
Posted

you can use freewares/sharewares Icon Creator/Editor for your need. But using VC++(which comes in Visual studio 6.0) you can do this because there is option in that.
 
Share this answer
 
v2
Thanx thatraja. But that's not what I wanted.

I want to draw a picture in runtime (depending on several states in the program) and use it as the icon for my form.

I got a possible solution from http://www.thevbzone.com/modICON.bas[^] where an ImageList is used to work around, using the function ListImage.ExtractIcon.
I'm just working on it and will post whether it will do the trick.

Thanks anyway for the quick reply.

Charlie.
 
Share this answer
 
WORKS!

You need a form object with an ImageList called "temp_IL" then add following code:

Function GetIcon _
    (ByVal Pic As StdPicture, _
     ByVal BackColor&, _
     Optional ByVal UseMask As Boolean, _
     Optional ByVal MaskColor&) As StdPicture
  If Pic = 0 Then Exit Function
  On Error GoTo 10
  With temp_IL
    .ListImages.Clear
    .ImageHeight = ScaleX(Pic.Height, vbHimetric, vbPixels)
    .ImageWidth = ScaleY(Pic.Width, vbHimetric, vbPixels)
    .BackColor = BackColor
    .MaskColor = MaskColor
    .UseMaskColor = UseMask
    Set GetIcon = .ListImages.Add(, , Pic).ExtractIcon
'    .ListImages.Clear
  End With
Exit Function
10:
  If Err.Number = 0 Then      ' No Error
    Resume Next
  ElseIf Err.Number = 20 Then ' Resume Without Error
    Err.Clear
    Resume Next
  Else                        ' Other Error
    Err.Clear
  End If
End Function


Right lads.
Cheers, Charlie
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900