No announcement yet.

Destroying Icons ?????

  • Filter
  • Time
  • Show
Clear All
new posts

  • Destroying Icons ?????

    I have a question:

    Loading a Bitmap and then later destroying it by using DeleteObject is very straightforward.

    What confuses me is destroying icons. The API docs say that you only use DestroyIcon for icons created with CreateIcon or CreateIconIndirect.

    While I can understand that an icon loaded from a resource probably shouldn't be destroyed at any time (in your app), how about icons that are loaded through LoadIcon or LoadImage which come from a disk file ?

    Can (and should) an icon loaded from a disk file be destroyed using Destroyicon ?
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"

  • #2
    Chris, I think the message is not to destroy a stock icon. I think
    this applies to all stock items, bitmaps,cursors,pens brushes etc.

    Regards, Jules


    • #3
      To the best of my knowledge, you can't destroy a stock object anyway, which is just as well. If we created a new font, and then deleted the old font as we selected the new one into a common device context, then we have a good chance of destroying the system font! However (luckily!) Windows just ignores the DeleteObject() call in such a case, so we can arbitarily attempt to delete all "stray" GDI objects without the need to validate each one before the attempt at destruction. The same applies to attempting to delete stock icons.

      Therefore, I would suggest that the correct answer to the original question is: Don't bother calling DestroyIcon() on an icon that was not created with CreateIconIndirect()... but don't worry if you do, as Windows will just ignore the attempt.

      PowerBASIC Support
      ( mailto:[email protected][email protected]</A> )
      mailto:[email protected]