home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / CUSTCNTL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  17.9 KB  |  511 lines

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