home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / msinc.pak / CUSTCNTL.H < prev    next >
C/C++ Source or Header  |  1997-07-23  |  19KB  |  532 lines

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * custcntl.h -  Custom Control Library header file                            *
  4. *                                                                             *
  5. \*****************************************************************************/
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 6.5
  9.  *
  10.  *      Copyright (c) 1994 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. #if !defined(__FLAT__)
  16. #ifndef __CUSTCNTL_H    /* prevent multiple includes */
  17. #define __CUSTCNTL_H
  18.  
  19. #ifndef __WINDOWS_H
  20. #include <windows.h>    /* <windows.h> must be included */
  21. #endif  /* __WINDOWS_H */
  22.  
  23. #ifndef RC_INVOKED
  24. #pragma option -a-      /* Assume byte packing throughout */
  25. #endif /* RC_INVOKED */
  26.  
  27. #ifdef __cplusplus
  28. extern "C" {            /* Assume C declarations for C++ */
  29. #endif  /* __cplusplus */
  30.  
  31. /* If included with the 3.0 windows.h, define compatible aliases */
  32. #if !defined(WINVER) || (WINVER < 0x030a)
  33. #define WINAPI      FAR PASCAL
  34. #define CALLBACK    FAR PASCAL
  35. #define LPCSTR      LPSTR
  36. #define UINT        WORD
  37. #define LPARAM      LONG
  38. #define WPARAM      WORD
  39. #define LRESULT     LONG
  40. #define HMODULE     HANDLE
  41. #define HINSTANCE   HANDLE
  42. #define HLOCAL      HANDLE
  43. #define HGLOBAL     HANDLE
  44. #endif  /* WIN3.0 */
  45.  
  46. /*
  47.  * Every custom control DLL must have three functions present,
  48.  * and they must be exported by the following ordinals.
  49.  */
  50. #define CCINFOORD       2       /* information function ordinal */
  51. #define CCSTYLEORD      3       /* styles function ordinal */
  52. #define CCFLAGSORD      4       /* translate flags function ordinal */
  53.  
  54. /* general size definitions */
  55. #define CTLTYPES        12      /* max number of control types */
  56. #define CTLDESCR        22      /* max size of description */
  57. #define CTLCLASS        20      /* max size of class name */
  58. #define CTLTITLE        94      /* max size of control text */
  59.  
  60. /*
  61.  * CONTROL STYLE DATA STRUCTURE
  62.  *
  63.  * This data structure is used by the class style dialog function
  64.  * to set and/or reset various control attributes.
  65.  *
  66.  */
  67. typedef struct tagCTLSTYLE
  68. {
  69.     UINT    wX;                 /* x origin of control */
  70.     UINT    wY;                 /* y origin of control */
  71.     UINT    wCx;                /* width of control */
  72.     UINT    wCy;                /* height of control */
  73.     UINT    wId;                /* control child id */
  74.     DWORD   dwStyle;            /* control style */
  75.     char    szClass[CTLCLASS];  /* name of control class */
  76.     char    szTitle[CTLTITLE];  /* control text */
  77. } CTLSTYLE;
  78. typedef CTLSTYLE *      PCTLSTYLE;
  79. typedef CTLSTYLE FAR*   LPCTLSTYLE;
  80.  
  81. /*
  82.  * CONTROL DATA STRUCTURE
  83.  *
  84.  * This data structure is returned by the control options function
  85.  * when inquiring about the capabilities of a particular control.
  86.  * Each control may contain various types (with predefined style
  87.  * bits) under one general class.
  88.  *
  89.  * The width and height fields are used to provide the host
  90.  * application with a suggested size.  The values in these fields
  91.  * are in rc coordinates.
  92.  *
  93.  */
  94. typedef struct tagCTLTYPE
  95. {
  96.     UINT    wType;              /* type style */
  97.     UINT    wWidth;             /* suggested width */
  98.     UINT    wHeight;            /* suggested height */
  99.     DWORD   dwStyle;            /* default style */
  100.     char    szDescr[CTLDESCR];  /* description */
  101. } CTLTYPE;
  102.  
  103. typedef struct tagCTLINFO
  104. {
  105.     UINT    wVersion;           /* control version */
  106.     UINT    wCtlTypes;          /* control types */
  107.     char    szClass[CTLCLASS];  /* control class name */
  108.     char    szTitle[CTLTITLE];  /* control title */
  109.     char    szReserved[10];     /* reserved for future use */
  110.     CTLTYPE Type[CTLTYPES];     /* control type list */
  111. } CTLINFO;
  112. typedef CTLINFO *       PCTLINFO;
  113. typedef CTLINFO FAR*    LPCTLINFO;
  114.  
  115. /* These two function prototypes are used by the dialog editor */
  116. #ifdef STRICT
  117. typedef DWORD   (CALLBACK* LPFNSTRTOID)(LPCSTR);
  118. #else
  119. typedef DWORD   (CALLBACK* LPFNSTRTOID)(LPSTR);
  120. #endif
  121. typedef UINT    (CALLBACK* LPFNIDTOSTR)(UINT, LPSTR, UINT);
  122.  
  123. /* function  prototypes left out of the original custcntl.h */
  124.  
  125. typedef HGLOBAL (CALLBACK *LPFNINFO)( void );
  126. typedef BOOL            (CALLBACK *LPFNSTYLE)
  127. (
  128.   HWND    hWnd,
  129.   HGLOBAL hCntlStyle,
  130.   LPFNSTRTOID lpfnSID,
  131.   LPFNIDTOSTR lpfnIDS
  132. );
  133.  
  134. typedef UINT   (CALLBACK *LPFNFLAGS)
  135. (
  136.   DWORD   dwStyle,
  137.   LPSTR   lpBuff,
  138.   UINT    wBuffLength
  139. );
  140.  
  141. /*****************************************************************************
  142.  
  143.   Resource Workshop has extended the MS Dialog editor's custom control
  144.   API in three main areas:
  145.  
  146.   1) More than 1 custom control can be placed in a single DLL
  147.  
  148.   2) The "Info" data structure has been extended to allow custom controls
  149.      to be added to the RW toolbox
  150.  
  151.   3) The style data structure has been extended to allow custom controls
  152.      access to the CTLDATA field. This field contains up to 255 bytes
  153.      of binary data. A pointer to this data is passed to the control
  154.      in the WM_CREATE message at runtime.
  155.  
  156.  
  157. *****************************************************************************/
  158.  
  159. /*****************************************************************************
  160.  
  161.   Two new fields have been added to the CTLTYPE data structure to
  162.   make the RWCTLTYPE structure:
  163.  
  164.   hToolBit is a handle to a 24X24 bitmap which is added to the
  165.   RW toolbox. If this field is 0, no button will be added for this style,
  166.   and it will only be selectable via the Custom control dialog. This bitmap
  167.   is "owned" by RW, and will be freed by RW when the dialog editor is
  168.   unloaded.
  169.  
  170.   hDropCurs is a handle to a cursor which is used by RW when a user
  171.   selects the control from the toolbox. If 0, a cross cursor will be used.
  172.  
  173.  
  174. *****************************************************************************/
  175.  
  176. #define TOOLBIT_SIZE  24
  177.  
  178. typedef struct
  179. {
  180.    UINT       wType;                  /* type style */
  181.    UINT       wWidth;                 /* suggested width */
  182.    UINT       wHeight;                /* suggested height */
  183.    DWORD      dwStyle;                /* default style */
  184.    char       szDescr[CTLDESCR];      /* dialog name */
  185.    HBITMAP    hToolBit;               // Toolbox bitmap
  186.    HCURSOR    hDropCurs;              // Drag and drop cursor
  187.  
  188. } RWCTLTYPE, FAR * LPRWCTLTYPE;
  189.  
  190. /*****************************************************************************
  191.  
  192.   This structure reflects the RWCTLTYPE data structure
  193.  
  194. *****************************************************************************/
  195.  
  196.  
  197. typedef struct
  198. {
  199.    UINT       wVersion;              /* control version */
  200.    UINT       wCtlTypes;             /* control types */
  201.    char       szClass[CTLCLASS];     /* control class name */
  202.    char       szTitle[CTLTITLE];     /* control title */
  203.    char       szReserved[10];        /* reserved for future use */
  204.    RWCTLTYPE  Type[CTLTYPES];        /* Resource Workshop control type list */
  205.  
  206. } RWCTLINFO;
  207.  
  208. typedef RWCTLINFO *             PRWCTLINFO;
  209. typedef RWCTLINFO FAR *         LPRWCTLINFO;
  210.  
  211. /*****************************************************************************
  212.  
  213.   Two new fields have been added to the CTLSTYLE data structure to make
  214.   the RWCTLSTYLE data structure:
  215.  
  216.   CtlDataSize is the size of
  217.   CtlData, which is an array of bytes passed to the control in the
  218.   WM_CREATE message.
  219.  
  220.  
  221. *****************************************************************************/
  222.  
  223. #define CTLDATALENGTH 255            // 255 bytes + Length Byte
  224.  
  225. typedef struct {
  226.   UINT    wX;                       /* x origin of control */
  227.   UINT    wY;                       /* y origin of control */
  228.   UINT    wCx;                      /* width of control */
  229.   UINT    wCy;                      /* height of control */
  230.   UINT    wId;                      /* control child id */
  231.   DWORD   dwStyle;                            /* control style */
  232.   char    szClass[CTLCLASS];        /* name of control class */
  233.   char    szTitle[CTLTITLE];        /* control text */
  234.   BYTE    CtlDataSize;              // Control data Size
  235.   BYTE    CtlData[ CTLDATALENGTH];  // Control data
  236.  
  237. } RWCTLSTYLE;
  238.  
  239. typedef RWCTLSTYLE *              PRWCTLSTYLE;
  240. typedef RWCTLSTYLE FAR *          LPRWCTLSTYLE;
  241.  
  242. /*****************************************************************************
  243.  
  244.   In order to use RW's extensions to the custom controls, a custom
  245.   control DLL *must* implement the ListClasses function. This function
  246.   returns a global memory handle to an initialized CTLCLASSLIST data
  247.   structure. All function pointers *must* point to valid functions.
  248.  
  249.  
  250. *****************************************************************************/
  251.  
  252. typedef struct
  253. {
  254.   LPFNINFO  fnRWInfo;           // RW Info function
  255.   LPFNSTYLE fnRWStyle;          // RW Style function
  256.   LPFNFLAGS fnFlags;            // Flags function
  257.   char  szClass[ CTLCLASS];
  258.  
  259. } RWCTLCLASS, FAR *LPRWCTLCLASS;
  260.  
  261. typedef struct
  262. {
  263.   short       nClasses;
  264. #if defined (__cplusplus)
  265.   RWCTLCLASS Classes[1];
  266. #else
  267.   RWCTLCLASS Classes[];
  268. #endif
  269.  
  270. } CTLCLASSLIST, FAR *LPCTLCLASSLIST;
  271.  
  272. #ifdef STRICT
  273. typedef HGLOBAL   (CALLBACK *LPFNLOADRES)( LPCSTR szType, LPCSTR szId);
  274. typedef BOOL      (CALLBACK *LPFNEDITRES)( LPCSTR szType, LPCSTR szId);
  275. #else
  276. typedef HGLOBAL   (CALLBACK *LPFNLOADRES)( LPSTR szType, LPSTR szId);
  277. typedef BOOL      (CALLBACK *LPFNEDITRES)( LPSTR szType, LPSTR szId);
  278. #endif
  279.  
  280. #ifdef STRICT
  281. typedef HGLOBAL (CALLBACK *LPFNLIST)
  282. (
  283.   LPSTR       szAppName,
  284.   UINT        wVersion,
  285.   LPFNLOADRES fnLoad,
  286.   LPFNEDITRES fnEdit
  287. );
  288. #else
  289. typedef HGLOBAL (CALLBACK *LPFNLIST)
  290. (
  291.   LPCSTR      szAppName,
  292.   UINT        wVersion,
  293.   LPFNLOADRES fnLoad,
  294.   LPFNEDITRES fnEdit
  295. );
  296. #endif
  297.  
  298. #define DLGCUSTCLASSNAME   "_BorDlg_DlgEditChild"
  299. #define DLGTESTCLASSNAME   "_BorDlg_DlgEditTest"
  300.  
  301.  
  302. // Rw version 1.02 and above send a message to a control
  303. // when the user is about to delete it. The message id
  304. // is that returned by RegisterWindowMessage, with the following
  305. // name:
  306.  
  307. #define RWDELETEMSGNAME "Rws_deletecontrol"
  308.  
  309.  
  310. #ifdef __cplusplus
  311. }
  312. #endif  /* __cplusplus */
  313.  
  314. #ifndef RC_INVOKED
  315. #pragma option -a.      /* Revert to default packing */
  316. #endif  /* RC_INVOKED */
  317.  
  318. #endif  /* __CUSTCNTL_H */
  319.  
  320. #else  /* !__FLAT__ */
  321. /*****************************************************************************\
  322. *                                                                             *
  323. * custcntl.h -  Custom Control Library header file                            *
  324. *                                                                             *
  325. *               Copyright (c) 1992-1995, Microsoft Corp.  All rights reserved *
  326. *                                                                             *
  327. \*****************************************************************************/
  328.  
  329. #ifndef _INC_CUSTCNTL
  330. #define _INC_CUSTCNTL
  331.  
  332. #ifdef __cplusplus
  333. extern "C" {            /* Assume C declarations for C++ */
  334. #endif  /* __cplusplus */
  335.  
  336.  
  337. /*
  338.  * General size defines.
  339.  */
  340. #define CCHCCCLASS          32          // Max chars in a class name.
  341. #define CCHCCDESC           32          // Max chars in a control description.
  342. #define CCHCCTEXT           256         // Max chars in a text field.
  343.  
  344.  
  345. /*
  346.  * CCSTYLE - Custom Control Style structure.  This structure is passed
  347.  * tp the Custom Control Style function when the user wants to edit the
  348.  * styles of the custom control.
  349.  */
  350. typedef struct tagCCSTYLEA {
  351.     DWORD   flStyle;                    // Style of the control.
  352.     DWORD   flExtStyle;                 // Extended style of the control.
  353.     CHAR    szText[CCHCCTEXT];          // Text of the control.
  354.     LANGID  lgid;                       // Language Id of the control's dialog.
  355.     WORD    wReserved1;                 // Reserved value.  Do not change.
  356. } CCSTYLEA, *LPCCSTYLEA;
  357.  
  358. typedef struct tagCCSTYLEW {
  359.     DWORD   flStyle;                    // Style of the control.
  360.     DWORD   flExtStyle;                 // Extended style of the control.
  361.     WCHAR   szText[CCHCCTEXT];          // Text of the control.
  362.     LANGID  lgid;                       // Language Id of the control's dialog.
  363.     WORD    wReserved1;                 // Reserved value.  Do not change.
  364. } CCSTYLEW, *LPCCSTYLEW;
  365.  
  366. #ifdef UNICODE
  367. #define CCSTYLE     CCSTYLEW
  368. #define LPCCSTYLE   LPCCSTYLEW
  369. #else
  370. #define CCSTYLE     CCSTYLEA
  371. #define LPCCSTYLE   LPCCSTYLEA
  372. #endif // UNICODE
  373.  
  374.  
  375. /*
  376.  * The Style function prototype.  This will be called when the user
  377.  * wants to edit the styles of a custom control.  It should display a
  378.  * dialog to edit the styles, update the styles in the pccs structure,
  379.  * then return TRUE for success.  If an error occurs or the user
  380.  * cancels the dialog, FALSE should be returned.
  381.  */
  382. typedef BOOL (CALLBACK* LPFNCCSTYLEA)(HWND hwndParent,  LPCCSTYLEA pccs);
  383. typedef BOOL (CALLBACK* LPFNCCSTYLEW)(HWND hwndParent,  LPCCSTYLEW pccs);
  384.  
  385. #ifdef UNICODE
  386. #define LPFNCCSTYLE LPFNCCSTYLEW
  387. #else
  388. #define LPFNCCSTYLE LPFNCCSTYLEA
  389. #endif  // UNICODE
  390.  
  391.  
  392. /*
  393.  * The SizeToText function prototype.  This will be called if the user
  394.  * requests that the custom control be sized to fit it's text.  It
  395.  * should use the specified styles, text and font to determine how
  396.  * large the control must be to accommodate the text, then return this
  397.  * value in pixels.  The value of -1 should be returned if an error
  398.  * occurs.
  399.  */
  400. typedef INT (CALLBACK* LPFNCCSIZETOTEXTA)(DWORD flStyle, DWORD flExtStyle,
  401.     HFONT hfont, LPSTR pszText);
  402. typedef INT (CALLBACK* LPFNCCSIZETOTEXTW)(DWORD flStyle, DWORD flExtStyle,
  403.     HFONT hfont, LPWSTR pszText);
  404.  
  405. #ifdef UNICODE
  406. #define LPFNCCSIZETOTEXT    LPFNCCSIZETOTEXTW
  407. #else
  408. #define LPFNCCSIZETOTEXT    LPFNCCSIZETOTEXTA
  409. #endif  // UNICODE
  410.  
  411.  
  412. /*
  413.  * CCSTYLEFLAG - Custom Control Style Flag structure.  A table of these
  414.  * structures is used to specify the define strings that match the
  415.  * different styles for a custom control.
  416.  */
  417. typedef struct tagCCSTYLEFLAGA {
  418.     DWORD flStyle;                      // Style bits for this style.
  419.     DWORD flStyleMask;                  // Mask for the style.  Can be zero.
  420.     LPSTR pszStyle;                     // Points to the style define string.
  421. } CCSTYLEFLAGA, *LPCCSTYLEFLAGA;
  422.  
  423. typedef struct tagCCSTYLEFLAGW {
  424.     DWORD flStyle;                      // Style bits for this style.
  425.     DWORD flStyleMask;                  // Mask for the style.  Can be zero.
  426.     LPWSTR pszStyle;                    // Points to the style define string.
  427. } CCSTYLEFLAGW, *LPCCSTYLEFLAGW;
  428.  
  429. #ifdef UNICODE
  430. #define CCSTYLEFLAG     CCSTYLEFLAGW
  431. #define LPCCSTYLEFLAG   LPCCSTYLEFLAGW
  432. #else
  433. #define CCSTYLEFLAG     CCSTYLEFLAGA
  434. #define LPCCSTYLEFLAG   LPCCSTYLEFLAGA
  435. #endif // UNICODE
  436.  
  437.  
  438. /*
  439.  * CCF_* defines.  These flags are used for the flOptions field of the
  440.  * CCINFO structure, and describe some basic characteristics of the
  441.  * custom control.
  442.  */
  443. #define CCF_NOTEXT          0x00000001  // Control cannot have text.
  444.  
  445.  
  446. /*
  447.  * CCINFO - Custom Control Info structure.  This structure provides
  448.  * the dialog editor with information about the control types that the
  449.  * DLL supports.
  450.  */
  451. typedef struct tagCCINFOA {
  452.     CHAR    szClass[CCHCCCLASS];        // Class name for the control.
  453.     DWORD   flOptions;                  // Option flags (CCF_* defines).
  454.     CHAR    szDesc[CCHCCDESC];          // Short, descriptive text for the ctrl.
  455.     UINT    cxDefault;                  // Default width (in dialog units).
  456.     UINT    cyDefault;                  // Default height (in dialog units).
  457.     DWORD   flStyleDefault;             // Default style (WS_CHILD | WS_VISIBLE).
  458.     DWORD   flExtStyleDefault;          // Default extended style.
  459.     DWORD   flCtrlTypeMask;             // Mask for control type styles.
  460.     CHAR    szTextDefault[CCHCCTEXT];   // Default text.
  461.     INT     cStyleFlags;                // Entries in the following style table.
  462.     LPCCSTYLEFLAGA aStyleFlags;         // Points to style flag table.
  463.     LPFNCCSTYLEA lpfnStyle;             // Pointer to the Styles function.
  464.     LPFNCCSIZETOTEXTA lpfnSizeToText;   // Pointer to the SizeToText function.
  465.     DWORD   dwReserved1;                // Reserved.  Must be zero.
  466.     DWORD   dwReserved2;                // Reserved.  Must be zero.
  467. } CCINFOA, *LPCCINFOA;
  468.  
  469. typedef struct tagCCINFOW {
  470.     WCHAR   szClass[CCHCCCLASS];        // Class name for the control.
  471.     DWORD   flOptions;                  // Option flags (CCF_* defines).
  472.     WCHAR   szDesc[CCHCCDESC];          // Short, descriptive text for the ctrl.
  473.     UINT    cxDefault;                  // Default width (in dialog units).
  474.     UINT    cyDefault;                  // Default height (in dialog units).
  475.     DWORD   flStyleDefault;             // Default style (WS_CHILD | WS_VISIBLE).
  476.     DWORD   flExtStyleDefault;          // Default extended style.
  477.     DWORD   flCtrlTypeMask;             // Mask for control type styles.
  478.     INT     cStyleFlags;                // Entries in the following style table.
  479.     LPCCSTYLEFLAGW aStyleFlags;         // Points to style flag table.
  480.     WCHAR   szTextDefault[CCHCCTEXT];   // Default text.
  481.     LPFNCCSTYLEW lpfnStyle;             // Pointer to the Styles function.
  482.     LPFNCCSIZETOTEXTW lpfnSizeToText;   // Pointer to the SizeToText function.
  483.     DWORD   dwReserved1;                // Reserved.  Must be zero.
  484.     DWORD   dwReserved2;                // Reserved.  Must be zero.
  485. } CCINFOW, *LPCCINFOW;
  486.  
  487. #ifdef UNICODE
  488. #define CCINFO      CCINFOW
  489. #define LPCCINFO    LPCCINFOW
  490. #else
  491. #define CCINFO      CCINFOA
  492. #define LPCCINFO    LPCCINFOA
  493. #endif // UNICODE
  494.  
  495.  
  496. /*
  497.  * The Info function prototype.  This function is the first one
  498.  * called by the dialog editor.  Custom control DLL's must export
  499.  * one or both of the following functions by name (the ordinal
  500.  * used for the export does not matter):
  501.  *
  502.  *  UINT CALLBACK CustomControlInfoA(LPCCINFOA acci)
  503.  *  UINT CALLBACK CustomControlInfoW(LPCCINFOW acci)
  504.  *
  505.  * This function must return the number of controls that the DLL
  506.  * supports, or NULL if an error occurs.  If the acci parameter is
  507.  * not NULL, it will be pointing to an array of CCINFOA or CCINFOW
  508.  * structures that should be filled in with the information about
  509.  * the different control types supported by the DLL.
  510.  *
  511.  * If both functions are present, the CustomControlInfoW function
  512.  * will be used by the dialog editor.
  513.  */
  514. typedef UINT (CALLBACK* LPFNCCINFOA)(LPCCINFOA acci);
  515. typedef UINT (CALLBACK* LPFNCCINFOW)(LPCCINFOW acci);
  516.  
  517. #ifdef UNICODE
  518. #define LPFNCCINFO  LPFNCCINFOW
  519. #else
  520. #define LPFNCCINFO  LPFNCCINFOA
  521. #endif  // UNICODE
  522.  
  523.  
  524. #ifdef __cplusplus
  525. }
  526. #endif  /* __cplusplus */
  527.  
  528. #endif  /* _INC_CUSTCNTL */
  529.  
  530.  
  531. #endif  /* __FLAT__ */
  532.