home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / custcntl.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  9KB  |  209 lines

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * custcntl.h -  Custom Control Library header file                            *
  4. *                                                                             *
  5. *               Copyright 1992 - 1998 Microsoft Corp.  All rights reserved *
  6. *                                                                             *
  7. \*****************************************************************************/
  8.  
  9. #ifndef _INC_CUSTCNTL
  10. #define _INC_CUSTCNTL
  11.  
  12. #ifdef __cplusplus
  13. extern "C" {            /* Assume C declarations for C++ */
  14. #endif  /* __cplusplus */
  15.  
  16.  
  17. /*
  18.  * General size defines.
  19.  */
  20. #define CCHCCCLASS          32          // Max chars in a class name.
  21. #define CCHCCDESC           32          // Max chars in a control description.
  22. #define CCHCCTEXT           256         // Max chars in a text field.
  23.  
  24.  
  25. /*
  26.  * CCSTYLE - Custom Control Style structure.  This structure is passed
  27.  * tp the Custom Control Style function when the user wants to edit the
  28.  * styles of the custom control.
  29.  */
  30. typedef struct tagCCSTYLEA {
  31.     DWORD   flStyle;                    // Style of the control.
  32.     DWORD   flExtStyle;                 // Extended style of the control.
  33.     CHAR    szText[CCHCCTEXT];          // Text of the control.
  34.     LANGID  lgid;                       // Language Id of the control's dialog.
  35.     WORD    wReserved1;                 // Reserved value.  Do not change.
  36. } CCSTYLEA, *LPCCSTYLEA;
  37.  
  38. typedef struct tagCCSTYLEW {
  39.     DWORD   flStyle;                    // Style of the control.
  40.     DWORD   flExtStyle;                 // Extended style of the control.
  41.     WCHAR   szText[CCHCCTEXT];          // Text of the control.
  42.     LANGID  lgid;                       // Language Id of the control's dialog.
  43.     WORD    wReserved1;                 // Reserved value.  Do not change.
  44. } CCSTYLEW, *LPCCSTYLEW;
  45.  
  46. #ifdef UNICODE
  47. #define CCSTYLE     CCSTYLEW
  48. #define LPCCSTYLE   LPCCSTYLEW
  49. #else
  50. #define CCSTYLE     CCSTYLEA
  51. #define LPCCSTYLE   LPCCSTYLEA
  52. #endif // UNICODE
  53.  
  54.  
  55. /*
  56.  * The Style function prototype.  This will be called when the user
  57.  * wants to edit the styles of a custom control.  It should display a
  58.  * dialog to edit the styles, update the styles in the pccs structure,
  59.  * then return TRUE for success.  If an error occurs or the user
  60.  * cancels the dialog, FALSE should be returned.
  61.  */
  62. typedef BOOL (CALLBACK* LPFNCCSTYLEA)(HWND hwndParent,  LPCCSTYLEA pccs);
  63. typedef BOOL (CALLBACK* LPFNCCSTYLEW)(HWND hwndParent,  LPCCSTYLEW pccs);
  64.  
  65. #ifdef UNICODE
  66. #define LPFNCCSTYLE LPFNCCSTYLEW
  67. #else
  68. #define LPFNCCSTYLE LPFNCCSTYLEA
  69. #endif  // UNICODE
  70.  
  71.  
  72. /*
  73.  * The SizeToText function prototype.  This will be called if the user
  74.  * requests that the custom control be sized to fit it's text.  It
  75.  * should use the specified styles, text and font to determine how
  76.  * large the control must be to accommodate the text, then return this
  77.  * value in pixels.  The value of -1 should be returned if an error
  78.  * occurs.
  79.  */
  80. typedef INT (CALLBACK* LPFNCCSIZETOTEXTA)(DWORD flStyle, DWORD flExtStyle,
  81.     HFONT hfont, LPSTR pszText);
  82. typedef INT (CALLBACK* LPFNCCSIZETOTEXTW)(DWORD flStyle, DWORD flExtStyle,
  83.     HFONT hfont, LPWSTR pszText);
  84.  
  85. #ifdef UNICODE
  86. #define LPFNCCSIZETOTEXT    LPFNCCSIZETOTEXTW
  87. #else
  88. #define LPFNCCSIZETOTEXT    LPFNCCSIZETOTEXTA
  89. #endif  // UNICODE
  90.  
  91.  
  92. /*
  93.  * CCSTYLEFLAG - Custom Control Style Flag structure.  A table of these
  94.  * structures is used to specify the define strings that match the
  95.  * different styles for a custom control.
  96.  */
  97. typedef struct tagCCSTYLEFLAGA {
  98.     DWORD flStyle;                      // Style bits for this style.
  99.     DWORD flStyleMask;                  // Mask for the style.  Can be zero.
  100.     LPSTR pszStyle;                     // Points to the style define string.
  101. } CCSTYLEFLAGA, *LPCCSTYLEFLAGA;
  102.  
  103. typedef struct tagCCSTYLEFLAGW {
  104.     DWORD flStyle;                      // Style bits for this style.
  105.     DWORD flStyleMask;                  // Mask for the style.  Can be zero.
  106.     LPWSTR pszStyle;                    // Points to the style define string.
  107. } CCSTYLEFLAGW, *LPCCSTYLEFLAGW;
  108.  
  109. #ifdef UNICODE
  110. #define CCSTYLEFLAG     CCSTYLEFLAGW
  111. #define LPCCSTYLEFLAG   LPCCSTYLEFLAGW
  112. #else
  113. #define CCSTYLEFLAG     CCSTYLEFLAGA
  114. #define LPCCSTYLEFLAG   LPCCSTYLEFLAGA
  115. #endif // UNICODE
  116.  
  117.  
  118. /*
  119.  * CCF_* defines.  These flags are used for the flOptions field of the
  120.  * CCINFO structure, and describe some basic characteristics of the
  121.  * custom control.
  122.  */
  123. #define CCF_NOTEXT          0x00000001  // Control cannot have text.
  124.  
  125.  
  126. /*
  127.  * CCINFO - Custom Control Info structure.  This structure provides
  128.  * the dialog editor with information about the control types that the
  129.  * DLL supports.
  130.  */
  131. typedef struct tagCCINFOA {
  132.     CHAR    szClass[CCHCCCLASS];        // Class name for the control.
  133.     DWORD   flOptions;                  // Option flags (CCF_* defines).
  134.     CHAR    szDesc[CCHCCDESC];          // Short, descriptive text for the ctrl.
  135.     UINT    cxDefault;                  // Default width (in dialog units).
  136.     UINT    cyDefault;                  // Default height (in dialog units).
  137.     DWORD   flStyleDefault;             // Default style (WS_CHILD | WS_VISIBLE).
  138.     DWORD   flExtStyleDefault;          // Default extended style.
  139.     DWORD   flCtrlTypeMask;             // Mask for control type styles.
  140.     CHAR    szTextDefault[CCHCCTEXT];   // Default text.
  141.     INT     cStyleFlags;                // Entries in the following style table.
  142.     LPCCSTYLEFLAGA aStyleFlags;         // Points to style flag table.
  143.     LPFNCCSTYLEA lpfnStyle;             // Pointer to the Styles function.
  144.     LPFNCCSIZETOTEXTA lpfnSizeToText;   // Pointer to the SizeToText function.
  145.     DWORD   dwReserved1;                // Reserved.  Must be zero.
  146.     DWORD   dwReserved2;                // Reserved.  Must be zero.
  147. } CCINFOA, *LPCCINFOA;
  148.  
  149. typedef struct tagCCINFOW {
  150.     WCHAR   szClass[CCHCCCLASS];        // Class name for the control.
  151.     DWORD   flOptions;                  // Option flags (CCF_* defines).
  152.     WCHAR   szDesc[CCHCCDESC];          // Short, descriptive text for the ctrl.
  153.     UINT    cxDefault;                  // Default width (in dialog units).
  154.     UINT    cyDefault;                  // Default height (in dialog units).
  155.     DWORD   flStyleDefault;             // Default style (WS_CHILD | WS_VISIBLE).
  156.     DWORD   flExtStyleDefault;          // Default extended style.
  157.     DWORD   flCtrlTypeMask;             // Mask for control type styles.
  158.     INT     cStyleFlags;                // Entries in the following style table.
  159.     LPCCSTYLEFLAGW aStyleFlags;         // Points to style flag table.
  160.     WCHAR   szTextDefault[CCHCCTEXT];   // Default text.
  161.     LPFNCCSTYLEW lpfnStyle;             // Pointer to the Styles function.
  162.     LPFNCCSIZETOTEXTW lpfnSizeToText;   // Pointer to the SizeToText function.
  163.     DWORD   dwReserved1;                // Reserved.  Must be zero.
  164.     DWORD   dwReserved2;                // Reserved.  Must be zero.
  165. } CCINFOW, *LPCCINFOW;
  166.  
  167. #ifdef UNICODE
  168. #define CCINFO      CCINFOW
  169. #define LPCCINFO    LPCCINFOW
  170. #else
  171. #define CCINFO      CCINFOA
  172. #define LPCCINFO    LPCCINFOA
  173. #endif // UNICODE
  174.  
  175.  
  176. /*
  177.  * The Info function prototype.  This function is the first one
  178.  * called by the dialog editor.  Custom control DLL's must export
  179.  * one or both of the following functions by name (the ordinal
  180.  * used for the export does not matter):
  181.  *
  182.  *  UINT CALLBACK CustomControlInfoA(LPCCINFOA acci)
  183.  *  UINT CALLBACK CustomControlInfoW(LPCCINFOW acci)
  184.  *
  185.  * This function must return the number of controls that the DLL
  186.  * supports, or NULL if an error occurs.  If the acci parameter is
  187.  * not NULL, it will be pointing to an array of CCINFOA or CCINFOW
  188.  * structures that should be filled in with the information about
  189.  * the different control types supported by the DLL.
  190.  *
  191.  * If both functions are present, the CustomControlInfoW function
  192.  * will be used by the dialog editor.
  193.  */
  194. typedef UINT (CALLBACK* LPFNCCINFOA)(LPCCINFOA acci);
  195. typedef UINT (CALLBACK* LPFNCCINFOW)(LPCCINFOW acci);
  196.  
  197. #ifdef UNICODE
  198. #define LPFNCCINFO  LPFNCCINFOW
  199. #else
  200. #define LPFNCCINFO  LPFNCCINFOA
  201. #endif  // UNICODE
  202.  
  203.  
  204. #ifdef __cplusplus
  205. }
  206. #endif  /* __cplusplus */
  207.  
  208. #endif  /* _INC_CUSTCNTL */
  209.