convgrp.h
Upload User: caisha3
Upload Date: 2013-09-21
Package Size: 208739k
Code Size: 9k
Category:

Windows Develop

Development Platform:

Visual C++

  1. /*++ BUILD Version: 0002    // Increment this if a change has global effects
  2. /****************************************************************************/
  3. /*                                                                          */
  4. /*  CONVGRP.H -                                                             */
  5. /*                                                                          */
  6. /*      Conversion from Win3.1 16 bit .grp file to NT 32bit .grp files for  */
  7. /*      the Program Manager                                                 */
  8. /*                                                                          */
  9. /*  Created: 10-15-92   Johanne Caron                                       */
  10. /*                                                                          */
  11. /****************************************************************************/
  12. #include <setjmp.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include <fcntl.h>
  16. #include <io.h>
  17. #include <stdio.h>
  18. #include <errno.h>
  19. #include <ctype.h>
  20. #include <windows.h>
  21. /*--------------------------------------------------------------------------*/
  22. /*                                                                          */
  23. /*  Typedefs                                                                */
  24. /*                                                                          */
  25. /*--------------------------------------------------------------------------*/
  26. /*
  27.  * .GRP File format structures -
  28.  */
  29. typedef struct tagGROUPDEF {
  30.     DWORD   dwMagic;        /* magical bytes 'PMCC' */
  31.     WORD    wCheckSum;      /* adjust this for zero sum of file */
  32.     WORD    cbGroup;        /* length of group segment */
  33.     RECT    rcNormal;       /* rectangle of normal window */
  34.     POINT   ptMin;          /* point of icon */
  35.     WORD    nCmdShow;       /* min, max, or normal state */
  36.     WORD    pName;          /* name of group */
  37.                             /* these four change interpretation */
  38.     WORD    cxIcon;         /* width of icons */
  39.     WORD    cyIcon;         /* hieght of icons */
  40.     WORD    wIconFormat;    /* planes and BPP in icons */
  41.     WORD    wReserved;      /* This word is no longer used. */
  42.     WORD    cItems;         /* number of items in group */
  43.     WORD    rgiItems[1];    /* array of ITEMDEF offsets */
  44. } GROUPDEF, *PGROUPDEF;
  45. typedef GROUPDEF *LPGROUPDEF;
  46. typedef struct tagITEMDEF {
  47.     POINT   pt;             /* location of item icon in group */
  48.     WORD    idIcon;         /* id of item icon */
  49.     WORD    wIconVer;       /* icon version */
  50.     WORD    cbIconRes;      /* size of icon resource */
  51.     WORD    indexIcon;      /* index of item icon */
  52.     WORD    dummy2;         /* - not used anymore */
  53.     WORD    pIconRes;       /* offset of icon resource */
  54.     WORD    dummy3;         /* - not used anymore */
  55.     WORD    pName;          /* offset of name string */
  56.     WORD    pCommand;       /* offset of command string */
  57.     WORD    pIconPath;      /* offset of icon path */
  58. } ITEMDEF, *PITEMDEF;
  59. typedef ITEMDEF *LPITEMDEF;
  60. /* the pointers in the above structures are short pointers relative to the
  61.  * beginning of the segments.  This macro converts the short pointer into
  62.  * a long pointer including the proper segment/selector value.        It assumes
  63.  * that its argument is an lvalue somewhere in a group segment, for example,
  64.  * PTR(lpgd->pName) returns a pointer to the group name, but k=lpgd->pName;
  65.  * PTR(k) is obviously wrong as it will use either SS or DS for its segment,
  66.  * depending on the storage class of k.
  67.  */
  68. #define PTR(base, offset) (LPSTR)((PBYTE)base + offset)
  69. /* PTR2 is used for those cases where a variable already contains an offset
  70.  * (The "case that doesn't work", above)
  71.  */
  72. #define PTR2(lp,offset) ((LPSTR)MAKELONG(offset,HIWORD(lp)))
  73. /* this macro is used to retrieve the i-th item in the group segment.  Note
  74.  * that this pointer will NOT be NULL for an unused slot.
  75.  */
  76. #define ITEM(lpgd,i) ((LPITEMDEF)PTR(lpgd, lpgd->rgiItems[i]))
  77. /*--------------------------------------------------------------------------*/
  78. /*                                                                          */
  79. /*  Tag Stuff                                                               */
  80. /*                                                                          */
  81. /*--------------------------------------------------------------------------*/
  82. typedef struct _tag
  83.   {
  84.     WORD wID;                   // tag identifier
  85.     WORD dummy1;                // need this for alignment!
  86.     int wItem;                  // (unde the covers 32 bit point!)item the tag belongs to
  87.     WORD cb;                    // size of record, including id and count
  88.     WORD dummy2;                // need this for alignment!
  89.     BYTE rgb[1];
  90.   } PMTAG, FAR * LPPMTAG;
  91. #define GROUP_MAGIC 0x43434D50L  /* 'PMCC' */
  92. #define PMTAG_MAGIC GROUP_MAGIC
  93.     /* range 8000 - 80FF > global
  94.      * range 8100 - 81FF > per item
  95.      * all others reserved
  96.      */
  97. #define ID_MAINTAIN             0x8000
  98.     /* bit used to indicate a tag that should be kept even if the writer
  99.      * doesn't recognize it.
  100.      */
  101. #define ID_MAGIC                0x8000
  102.     /* data: the string 'TAGS'
  103.      */
  104. #define ID_WRITERVERSION        0x8001
  105.     /* data: string in the form [9]9.99[Z].99
  106.      */
  107. #define ID_APPLICATIONDIR       0x8101
  108.     /* data: ASCIZ string of directory where application may be
  109.      * located.
  110.      * this is defined as application dir rather than default dir
  111.      * since the default dir is explicit in the 3.0 command line and
  112.      * must stay there.  The true "new information" is the application
  113.      * directory.  If not present, search the path.
  114.      */
  115. #define ID_HOTKEY               0x8102
  116.     /* data: WORD hotkey index
  117.      */
  118. #define ID_MINIMIZE             0x8103
  119.     /* data none
  120.      */
  121. #define ID_LASTTAG              0xFFFF
  122.     /* the last tag in the file
  123.      */
  124.     /*
  125.      * Maximium number of items allowed in a group
  126.      */
  127. #define CITEMSMAX 50
  128. /*--------------------------------------------------------------------------*/
  129. /*--------------------------------------------------------------------------*/
  130. //
  131. // This is the structure of the .grp files in Windows3.1
  132. //
  133. /* .GRP File format structures -
  134.  */
  135. typedef struct tagGROUPDEF16
  136.   {
  137.     DWORD   dwMagic;       /* magical bytes 'PMCC' */
  138.     WORD   wCheckSum;       /* adjust this for zero sum of file */
  139.     WORD   cbGroup;       /* length of group segment */
  140.     WORD   nCmdShow;       /* min, max, or normal state */
  141.     SMALL_RECT rcNormal;       /* rectangle of normal window */
  142.     POINTS   ptMin;       /* point of icon */
  143.     WORD   pName;       /* name of group */
  144.     /* these four change interpretation */
  145.     WORD   cxIcon;       /* width of icons */
  146.     WORD   cyIcon;       /* hieght of icons */
  147.     WORD   wIconFormat;       /* planes and BPP in icons */
  148.     WORD   wReserved;       /* This word is no longer used. */
  149.     WORD   cItems;       /* number of items in group */
  150.     WORD   rgiItems[1];       /* array of ITEMDEF offsets */
  151.   } GROUPDEF16;
  152. typedef GROUPDEF16 *LPGROUPDEF16;
  153. /* this macro is used to retrieve the i-th item in the group segment.  Note
  154.  * that this pointer will NOT be NULL for an unused slot.
  155.  */
  156. #define ITEM16(lpgd16,i) ((LPBYTE)PTR(lpgd16, lpgd16->rgiItems[i]))
  157. #if 0
  158. //
  159. // These structures are not needed for the conversion but it is useful to
  160. // understand what is going on.
  161. //
  162. typedef struct tagITEMDEF16
  163.   {
  164.     POINTS    pt;       /* location of item icon in group */
  165.                                       // NB This is read when a group is
  166.                                       // loaded and updated when a group is
  167.                                       // written.  All painting/moving is
  168.                                       // done using the icon and title rects
  169.                                       // in an ITEM.  So if you want to know
  170.                                       // where an item is use it's icon rect
  171.                                       // not it's point.
  172.     WORD   iIcon;       /* index of item icon */
  173.     WORD   cbHeader;       /* size of icon header */
  174.     WORD   cbANDPlane;       /* size of and part of icon */
  175.     WORD   cbXORPlane;       /* size of xor part of icon */
  176.     WORD   pHeader;       /* file offset of icon header */
  177.     WORD   pANDPlane;       /* file offset of AND plane */
  178.     WORD   pXORPlane;       /* file offset of XOR plane */
  179.     WORD   pName;       /* file offset of name string */
  180.     WORD   pCommand;       /* file offset of command string */
  181.     WORD   pIconPath;       /* file offset of icon path */
  182.   } ITEMDEF16;
  183. typedef ITEMDEF16 *LPITEMDEF16;
  184. typedef struct _tag16
  185.   {
  186.     WORD wID; // tag identifier
  187.     WORD wItem;  // item the tag belongs to
  188.     WORD cb; // size of record, including id and count
  189.     BYTE rgb[1];
  190.   } TAG16, * LPTAG16;
  191. #endif
  192. //
  193. // Globals
  194. //
  195. HANDLE hInst;