Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does CopyIcon need to Destroy the Handle

Status
Not open for further replies.

RMS001

Programmer
Nov 12, 2002
45
CA
Hi - It's been a while since I visited. The best VB6 help was always here.

Is there a reference created, or simply a long variable assigned a value, when using CopyIcon?

Private Sub Form_Load()
hIcon = CopyIcon(Image1.Picture.Handle)
End Sub

Private Sub Form_Paint()
DrawIconEx Picture1.hdc, 10, 10, hIcon, 12, 12, 0&, 0&, DI_NORMAL
End Sub

'is this neccessary
Private Sub Form_Unload(Cancel As Integer)
DestroyIcon hIcon
End Sub
 
DestroyIcon not only destroys the icon it also frees any memory associated with the copied icon, so yes, it's best to use it once you're finished.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
I'd use DestroyIcon, since there may be some system resources allocated by the CopyIcon call that are only freed on DestroyIcon
 
Thankyou both. strongm - thanks for all your terrific advice over the years...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top