ICONS.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /****************************************************************************
  2. *  
  3. *     FILE:     Icons.H
  4. *
  5. *     PURPOSE:  IconPro Project Icon handling header file
  6. *
  7. *     COMMENTS: 
  8. *               
  9. *
  10. *     Copyright 1995 - 1997 Microsoft Corp.
  11. *
  12. *
  13. * History:
  14. *                July '95 - Created
  15. *
  16. ****************************************************************************/
  17. /****************************************************************************/
  18. // Structs
  19. // These first two structs represent how the icon information is stored
  20. // when it is bound into a EXE or DLL file. Structure members are WORD
  21. // aligned and the last member of the structure is the ID instead of
  22. // the imageoffset.
  23. #pragma pack( push )
  24. #pragma pack( 2 )
  25. typedef struct
  26. {
  27. BYTE bWidth;               // Width of the image
  28. BYTE bHeight;              // Height of the image (times 2)
  29. BYTE bColorCount;          // Number of colors in image (0 if >=8bpp)
  30. BYTE bReserved;            // Reserved
  31. WORD wPlanes;              // Color Planes
  32. WORD wBitCount;            // Bits per pixel
  33. DWORD dwBytesInRes;         // how many bytes in this resource?
  34. WORD nID;                  // the ID
  35. } MEMICONDIRENTRY, *LPMEMICONDIRENTRY;
  36. typedef struct 
  37. {
  38. WORD idReserved;   // Reserved
  39. WORD idType;       // resource type (1 for icons)
  40. WORD idCount;      // how many images?
  41. MEMICONDIRENTRY idEntries[1]; // the entries for each image
  42. } MEMICONDIR, *LPMEMICONDIR;
  43. #pragma pack( pop )
  44. // These next two structs represent how the icon information is stored
  45. // in an ICO file.
  46. typedef struct
  47. {
  48. BYTE bWidth;               // Width of the image
  49. BYTE bHeight;              // Height of the image (times 2)
  50. BYTE bColorCount;          // Number of colors in image (0 if >=8bpp)
  51. BYTE bReserved;            // Reserved
  52. WORD wPlanes;              // Color Planes
  53. WORD wBitCount;            // Bits per pixel
  54. DWORD dwBytesInRes;         // how many bytes in this resource?
  55. DWORD dwImageOffset;        // where in the file is this image
  56. } ICONDIRENTRY, *LPICONDIRENTRY;
  57. typedef struct 
  58. {
  59. WORD idReserved;   // Reserved
  60. WORD idType;       // resource type (1 for icons)
  61. WORD idCount;      // how many images?
  62. ICONDIRENTRY idEntries[1]; // the entries for each image
  63. } ICONDIR, *LPICONDIR;
  64. // The following two structs are for the use of this program in
  65. // manipulating icons. They are more closely tied to the operation
  66. // of this program than the structures listed above. One of the
  67. // main differences is that they provide a pointer to the DIB
  68. // information of the masks.
  69. typedef struct
  70. {
  71. UINT Width, Height, Colors; // Width, Height and bpp
  72. LPBYTE lpBits;                // ptr to DIB bits
  73. DWORD dwNumBytes;            // how many bytes?
  74. LPBITMAPINFO lpbi;                  // ptr to header
  75. LPBYTE lpXOR;                 // ptr to XOR image bits
  76. LPBYTE lpAND;                 // ptr to AND image bits
  77. } ICONIMAGE, *LPICONIMAGE;
  78. typedef struct
  79. {
  80. BOOL bHasChanged;                     // Has image changed?
  81. TCHAR szOriginalICOFileName[MAX_PATH]; // Original name
  82. TCHAR szOriginalDLLFileName[MAX_PATH]; // Original name
  83. UINT nNumImages;                      // How many images?
  84. ICONIMAGE IconImages[1];                   // Image entries
  85. } ICONRESOURCE, *LPICONRESOURCE;
  86. /****************************************************************************/
  87. /****************************************************************************/
  88. // Exported function prototypes
  89. LPICONRESOURCE ReadIconFromICOFile( LPCTSTR szFileName );
  90. BOOL WriteIconToICOFile( LPICONRESOURCE lpIR, LPCTSTR szFileName );
  91. HICON MakeIconFromResource( LPICONIMAGE lpIcon );
  92. LPICONRESOURCE ReadIconFromEXEFile( LPCTSTR szFileName );
  93. BOOL IconImageToClipBoard( LPICONIMAGE lpii );
  94. BOOL IconImageFromClipBoard( LPICONIMAGE lpii, BOOL bStretchToFit );
  95. BOOL CreateBlankNewFormatIcon( LPICONIMAGE lpii );
  96. BOOL DrawXORMask( HDC hDC, RECT Rect, LPICONIMAGE lpIcon );
  97. BOOL DrawANDMask( HDC hDC, RECT Rect, LPICONIMAGE lpIcon );
  98. RECT GetXORImageRect( RECT Rect, LPICONIMAGE lpIcon );
  99. BOOL MakeNewANDMaskBasedOnPoint( LPICONIMAGE lpIcon, POINT pt );
  100. BOOL IconImageFromBMPFile( LPCTSTR szFileName, LPICONIMAGE lpii, BOOL bStretchToFit );
  101. BOOL IconImageToBMPFile( LPCTSTR szFileName, LPICONIMAGE lpii );
  102. /****************************************************************************/