Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 000
  5. *
  6. * File: xmlimage.cpp
  7. *
  8. * Contents: Implementation file for CXMLImageList
  9. *
  10. * History: 10-Aug-2000 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #include "xmlimage.h"
  14. #include "util.h"
  15. /*+-------------------------------------------------------------------------*
  16. * CXMLImageList::Persist
  17. *
  18. * Saves/loads a CXMLImageList to a CPersistor.
  19. *--------------------------------------------------------------------------*/
  20. void CXMLImageList::Persist (CPersistor &persistor)
  21. {
  22. DECLARE_SC (sc, _T("CXMLImageList::Persist"));
  23. // try to get IStream first, to avoid cleanup if it fails [and throws] (audriusz)
  24. CXML_IStream xmlStream;
  25. if (persistor.IsStoring())
  26. {
  27. ASSERT (!IsNull());
  28. /*
  29. * write the imagelist to the stream
  30. */
  31. IStreamPtr spStream;
  32. sc = xmlStream.ScGetIStream( &spStream );
  33. if (sc)
  34. sc.Throw();
  35. sc = WriteCompatibleImageList (m_hImageList, spStream);
  36. if (sc)
  37. sc.Throw();
  38. }
  39. xmlStream.Persist (persistor);
  40. if (persistor.IsLoading())
  41. {
  42. /*
  43. * get rid of the imagelist that's there, if any
  44. */
  45. Destroy();
  46. ASSERT (IsNull());
  47. /*
  48. * reconstitute the imagelist from the stream
  49. */
  50. IStreamPtr spStream;
  51. sc = xmlStream.ScGetIStream( &spStream );
  52. if (sc)
  53. sc.Throw();
  54. sc = ReadCompatibleImageList (spStream, m_hImageList);
  55. if (sc)
  56. sc.Throw();
  57. }
  58. }