home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 7.ddi / WINCLUDE.ZIP / CUSTCNTL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  10.2 KB  |  309 lines

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * custcntl.h -  Custom Control Library header file                            *
  4. *                                                                             *
  5. \*****************************************************************************/
  6.  
  7. #ifndef __CUSTCNTL_H    /* prevent multiple includes */
  8. #define __CUSTCNTL_H
  9.  
  10. #ifndef __WINDOWS_H
  11. #include <windows.h>    /* <windows.h> must be included */
  12. #endif  /* __WINDOWS_H */
  13.  
  14. #ifndef RC_INVOKED
  15. #pragma option -a-      /* Assume byte packing throughout */
  16. #endif /* RC_INVOKED */
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {            /* Assume C declarations for C++ */
  20. #endif  /* __cplusplus */
  21.  
  22. /* If included with the 3.0 windows.h, define compatible aliases */
  23. #if !defined(WINVER) || (WINVER < 0x030a)
  24. #define WINAPI      FAR PASCAL
  25. #define CALLBACK    FAR PASCAL
  26. #define LPCSTR      LPSTR
  27. #define UINT        WORD
  28. #define LPARAM      LONG
  29. #define WPARAM      WORD
  30. #define LRESULT     LONG
  31. #define HMODULE     HANDLE
  32. #define HINSTANCE   HANDLE
  33. #define HLOCAL      HANDLE
  34. #define HGLOBAL     HANDLE
  35. #endif  /* WIN3.0 */
  36.  
  37. /*
  38.  * Every custom control DLL must have three functions present,
  39.  * and they must be exported by the following ordinals.
  40.  */
  41. #define CCINFOORD       2       /* information function ordinal */
  42. #define CCSTYLEORD      3       /* styles function ordinal */
  43. #define CCFLAGSORD      4       /* translate flags function ordinal */
  44.  
  45. /* general size definitions */
  46. #define CTLTYPES        12      /* max number of control types */
  47. #define CTLDESCR        22      /* max size of description */
  48. #define CTLCLASS        20      /* max size of class name */
  49. #define CTLTITLE        94      /* max size of control text */
  50.  
  51. /*
  52.  * CONTROL STYLE DATA STRUCTURE
  53.  *
  54.  * This data structure is used by the class style dialog function
  55.  * to set and/or reset various control attributes.
  56.  *
  57.  */
  58. typedef struct tagCTLSTYLE
  59. {
  60.     UINT    wX;                 /* x origin of control */
  61.     UINT    wY;                 /* y origin of control */
  62.     UINT    wCx;                /* width of control */
  63.     UINT    wCy;                /* height of control */
  64.     UINT    wId;                /* control child id */
  65.     DWORD   dwStyle;            /* control style */
  66.     char    szClass[CTLCLASS];  /* name of control class */
  67.     char    szTitle[CTLTITLE];  /* control text */
  68. } CTLSTYLE;
  69. typedef CTLSTYLE *      PCTLSTYLE;
  70. typedef CTLSTYLE FAR*   LPCTLSTYLE;
  71.  
  72. /*
  73.  * CONTROL DATA STRUCTURE
  74.  *
  75.  * This data structure is returned by the control options function
  76.  * when inquiring about the capabilities of a particular control.
  77.  * Each control may contain various types (with predefined style
  78.  * bits) under one general class.
  79.  *
  80.  * The width and height fields are used to provide the host
  81.  * application with a suggested size.  The values in these fields
  82.  * are in rc coordinates.
  83.  *
  84.  */
  85. typedef struct tagCTLTYPE
  86. {
  87.     UINT    wType;              /* type style */
  88.     UINT    wWidth;             /* suggested width */
  89.     UINT    wHeight;            /* suggested height */
  90.     DWORD   dwStyle;            /* default style */
  91.     char    szDescr[CTLDESCR];  /* description */
  92. } CTLTYPE;
  93.  
  94. typedef struct tagCTLINFO
  95. {
  96.     UINT    wVersion;           /* control version */
  97.     UINT    wCtlTypes;          /* control types */
  98.     char    szClass[CTLCLASS];  /* control class name */
  99.     char    szTitle[CTLTITLE];  /* control title */
  100.     char    szReserved[10];     /* reserved for future use */
  101.     CTLTYPE Type[CTLTYPES];     /* control type list */
  102. } CTLINFO;
  103. typedef CTLINFO *       PCTLINFO;
  104. typedef CTLINFO FAR*    LPCTLINFO;
  105.  
  106. /* These two function prototypes are used by the dialog editor */
  107. #ifdef STRICT
  108. typedef DWORD   (CALLBACK* LPFNSTRTOID)(LPCSTR);
  109. #else
  110. typedef DWORD   (CALLBACK* LPFNSTRTOID)(LPSTR);
  111. #endif
  112. typedef UINT    (CALLBACK* LPFNIDTOSTR)(UINT, LPSTR, UINT);
  113.  
  114. /* function  prototypes left out of the original custcntl.h */
  115.  
  116. typedef HGLOBAL (CALLBACK *LPFNINFO)( void );
  117. typedef BOOL            (CALLBACK *LPFNSTYLE)
  118. (
  119.   HWND    hWnd,
  120.   HGLOBAL hCntlStyle,
  121.   LPFNSTRTOID lpfnSID,
  122.   LPFNIDTOSTR lpfnIDS
  123. );
  124.  
  125. typedef UINT   (CALLBACK *LPFNFLAGS)
  126. (
  127.   DWORD   dwStyle,
  128.   LPSTR   lpBuff,
  129.   UINT    wBuffLength
  130. );
  131.  
  132. /*****************************************************************************
  133.  
  134.   Resource Workshop has extended the MS Dialog editor's custom control
  135.   API in three main areas:
  136.  
  137.   1) More than 1 custom control can be placed in a single DLL
  138.  
  139.   2) The "Info" data structure has been extended to allow custom controls
  140.      to be added to the RW toolbox
  141.  
  142.   3) The style data structure has been extended to allow custom controls
  143.      access to the CTLDATA field. This field contains up to 255 bytes
  144.      of binary data. A pointer to this data is passed to the control
  145.      in the WM_CREATE message at runtime.
  146.  
  147.  
  148. *****************************************************************************/
  149.  
  150. /*****************************************************************************
  151.  
  152.   Two new fields have been added to the CTLTYPE data structure to
  153.   make the RWCTLTYPE structure:
  154.  
  155.   hToolBit is a handle to a 24X24 bitmap which is added to the
  156.   RW toolbox. If this field is 0, no button will be added for this style,
  157.   and it will only be selectable via the Custom control dialog. This bitmap
  158.   is "owned" by RW, and will be freed by RW when the dialog editor is
  159.   unloaded.
  160.  
  161.   hDropCurs is a handle to a cursor which is used by RW when a user
  162.   selects the control from the toolbox. If 0, a cross cursor will be used.
  163.  
  164.  
  165. *****************************************************************************/
  166.  
  167. #define TOOLBIT_SIZE  24
  168.  
  169. typedef struct
  170. {
  171.    UINT       wType;                  /* type style */
  172.    UINT       wWidth;                 /* suggested width */
  173.    UINT       wHeight;                /* suggested height */
  174.    DWORD      dwStyle;                /* default style */
  175.    char       szDescr[CTLDESCR];      /* dialog name */
  176.    HBITMAP    hToolBit;               // Toolbox bitmap
  177.    HCURSOR    hDropCurs;              // Drag and drop cursor
  178.  
  179. } RWCTLTYPE, FAR * LPRWCTLTYPE;
  180.  
  181. /*****************************************************************************
  182.  
  183.   This structure reflects the RWCTLTYPE data structure
  184.  
  185. *****************************************************************************/
  186.  
  187.  
  188. typedef struct
  189. {
  190.    UINT       wVersion;              /* control version */
  191.    UINT       wCtlTypes;             /* control types */
  192.    char       szClass[CTLCLASS];     /* control class name */
  193.    char       szTitle[CTLTITLE];     /* control title */
  194.    char       szReserved[10];        /* reserved for future use */
  195.    RWCTLTYPE  Type[CTLTYPES];        /* Resource Workshop control type list */
  196.  
  197. } RWCTLINFO;
  198.  
  199. typedef RWCTLINFO *             PRWCTLINFO;
  200. typedef RWCTLINFO FAR *         LPRWCTLINFO;
  201.  
  202. /*****************************************************************************
  203.  
  204.   Two new fields have been added to the CTLSTYLE data structure to make
  205.   the RWCTLSTYLE data structure:
  206.  
  207.   CtlDataSize is the size of
  208.   CtlData, which is an array of bytes passed to the control in the
  209.   WM_CREATE message.
  210.  
  211.  
  212. *****************************************************************************/
  213.  
  214. #define CTLDATALENGTH 255            // 255 bytes + Length Byte
  215.  
  216. typedef struct {
  217.   UINT    wX;                       /* x origin of control */
  218.   UINT    wY;                       /* y origin of control */
  219.   UINT    wCx;                      /* width of control */
  220.   UINT    wCy;                      /* height of control */
  221.   UINT    wId;                      /* control child id */
  222.   DWORD   dwStyle;                            /* control style */
  223.   char    szClass[CTLCLASS];        /* name of control class */
  224.   char    szTitle[CTLTITLE];        /* control text */
  225.   BYTE    CtlDataSize;              // Control data Size
  226.   BYTE    CtlData[ CTLDATALENGTH];  // Control data
  227.  
  228. } RWCTLSTYLE;
  229.  
  230. typedef RWCTLSTYLE *              PRWCTLSTYLE;
  231. typedef RWCTLSTYLE FAR *          LPRWCTLSTYLE;
  232.  
  233. /*****************************************************************************
  234.  
  235.   In order to use RW's extensions to the custom controls, a custom
  236.   control DLL *must* implement the ListClasses function. This function
  237.   returns a global memory handle to an initialized CTLCLASSLIST data
  238.   structure. All function pointers *must* point to valid functions.
  239.  
  240.  
  241. *****************************************************************************/
  242.  
  243. typedef struct
  244. {
  245.   LPFNINFO  fnRWInfo;           // RW Info function
  246.   LPFNSTYLE fnRWStyle;          // RW Style function
  247.   LPFNFLAGS fnFlags;            // Flags function
  248.   char  szClass[ CTLCLASS];
  249.  
  250. } RWCTLCLASS, FAR *LPRWCTLCLASS;
  251.  
  252. typedef struct
  253. {
  254.   short       nClasses;
  255. #if defined (__cplusplus)
  256.   RWCTLCLASS Classes[1];
  257. #else
  258.   RWCTLCLASS Classes[];
  259. #endif
  260.  
  261. } CTLCLASSLIST, FAR *LPCTLCLASSLIST;
  262.  
  263. #ifdef STRICT
  264. typedef HGLOBAL   (CALLBACK *LPFNLOADRES)( LPCSTR szType, LPCSTR szId);
  265. typedef BOOL      (CALLBACK *LPFNEDITRES)( LPCSTR szType, LPCSTR szId);
  266. #else
  267. typedef HGLOBAL   (CALLBACK *LPFNLOADRES)( LPSTR szType, LPSTR szId);
  268. typedef BOOL      (CALLBACK *LPFNEDITRES)( LPSTR szType, LPSTR szId);
  269. #endif
  270.  
  271. #ifdef STRICT
  272. typedef HGLOBAL (CALLBACK *LPFNLIST)
  273. (
  274.   LPSTR       szAppName,
  275.   UINT        wVersion,
  276.   LPFNLOADRES fnLoad,
  277.   LPFNEDITRES fnEdit
  278. );
  279. #else
  280. typedef HGLOBAL (CALLBACK *LPFNLIST)
  281. (
  282.   LPCSTR      szAppName,
  283.   UINT        wVersion,
  284.   LPFNLOADRES fnLoad,
  285.   LPFNEDITRES fnEdit
  286. );
  287. #endif
  288.  
  289. #define DLGCUSTCLASSNAME   "_BorDlg_DlgEditChild"
  290. #define DLGTESTCLASSNAME   "_BorDlg_DlgEditTest"
  291.  
  292.  
  293. // Rw version 1.02 and above send a message to a control
  294. // when the user is about to delete it. The message id
  295. // is that returned by RegisterWindowMessage, with the following
  296. // name:
  297.  
  298. #define RWDELETEMSGNAME "Rws_deletecontrol"
  299.  
  300. #ifdef __cplusplus
  301. }                       /* End of extern "C" { */
  302. #endif  /* __cplusplus */
  303.  
  304. #ifndef RC_INVOKED
  305. #pragma option -a.      /* Revert to default packing */
  306. #endif  /* RC_INVOKED */
  307.  
  308. #endif  /* __CUSTCNTL_H */
  309.