home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 20.ddi / DOC.PAK / CUSTCNTL.TXT < prev    next >
Encoding:
Text File  |  1993-12-02  |  32.7 KB  |  840 lines

  1.                            CUSTCNTL.RW
  2.                            ===========
  3.  
  4. =============================================================
  5. CREATING CUSTOM CONTROL CLASSES
  6. =============================================================
  7. Windows provides standard control classes, such as list boxes
  8. and radio buttons, that you can add to your dialog box
  9. resources. In addition to these standard classes, Resource
  10. Workshop also lets you create and use custom control classes,
  11. which must be in a DLL (dynamic-link library). This file
  12. describes the functions you'll need to use to make your
  13. custom controls accessible to Resource Workshop.
  14.  
  15. The DLL file of custom controls must contain functions that
  16. let Resource Workshop work with the custom controls just as it
  17. works with the standard Windows controls. In particular, you
  18. must implement the ListClasses function and export it by name.
  19. This function provides information to Resource Workshop about
  20. the custom control classes in the DLL.
  21.  
  22. You must also provide the following functions for each custom
  23. control window class:
  24.  
  25.      - Info
  26.      - Style
  27.      - Flags
  28.  
  29. These functions can have any name. They must, however, be
  30. exported by the DLL, and pointers to them must be supplied in the
  31. ListClasses function.
  32.  
  33.  
  34. =============================================================
  35. USING C TO CREATE CUSTOM CONTROLS
  36. =============================================================
  37.  
  38. ListClasses function
  39. --------------------
  40. ListClasses is a programmer-implemented function that passes
  41. information about the custom control classes back to Resource
  42. Workshop. Exporting ListClasses marks your DLL as supporting this
  43. custom control specification.
  44.  
  45. If ListClasses is present in the DLL, Resource Workshop calls the
  46. function, passing information about itself along with two utility
  47. function variables used in editing the custom control.
  48.  
  49. ListClasses should return a handle to global memory allocated by
  50. calling GlobalAlloc. The memory referenced by this handle holds
  51. a structure of type CTLCLASSLIST, which describes the controls in
  52. the library. CTLCLASSLIST is described later in this section.
  53. The handle is freed by Resource Workshop and should not be freed
  54. by the DLL.
  55.  
  56. Return value:
  57.  
  58.    Returns a global handle to the data structure.
  59.  
  60. Syntax:
  61.  
  62.    HGLOBAL CALLBACK ListClasses( LPSTR szAppClass, UINT wVersion,
  63.    LPFNLOADRES fnLoad, LPFNEDITRES fnEdit);
  64.  
  65. Parameters:
  66.  
  67.    szAppClass   The class name of the application's main
  68.                 window. The class name can be used by the
  69.                 custom control to determine if it is running
  70.                 under a resource editor. If szAppClass is
  71.                 "rwswnd", the calling application is
  72.                 Resource Workshop.
  73.  
  74.    wVersion     The version number of the calling application.
  75.                 The major version is in the high-order byte
  76.                 and the minor version in the low-order byte.
  77.                 For example, version 1.02 is 0x0102.
  78.  
  79.    fnLoad       A pointer to a that function a custom control
  80.                 can use to get a binary version of any
  81.                 resource in the project being edited by the
  82.                 calling application--the equivalent of the
  83.                 Windows API function LoadResource(). The
  84.                 function takes two parameters: a resource
  85.                 type name and a resource name. The custom
  86.                 control must free the global handle (if any)
  87.                 returned by the function.
  88.  
  89.    fnEdit       A pointer to a function that a custom control
  90.                 can use to start a resource editor for any
  91.                 resource in the project being edited by
  92.                 Resource Workshop. It takes two parameters:
  93.                 a resource type name and a resource name.
  94.  
  95. Data structures:
  96.  
  97.    typedef struct
  98.    {
  99.      LPFNINFO  fnRWInfo;             // Info function
  100.      LPFNSTYLE fnRWStyle;            // Style function
  101.      LPFNFLAGS fnFlags;              // Flags function
  102.      char  szClass[ CTLCLASS];       // Class name
  103.  
  104.    } RWCTLCLASS, FAR *LPRWCTLCLASS;
  105.  
  106.    typedef struct {
  107.      short  nClasses;          // Number of classes in list
  108.      RWCTLCLASS Classes[];     // Class list
  109.    } CTLCLASSLIST, FAR *LPCTLCLASSLIST;
  110.  
  111.    The CTLCLASSLIST structure contains a variable number of
  112.    RWCTLCLASS strucures, the number of which is determined by
  113.    the nClasses field.
  114.  
  115.    Each control class in the DLL must have a corresponding
  116.    RWCTLCLASS structure in the CTLCLASSLIST. The szClass field
  117.    contains the name with which the class was registered. For
  118.    example, if you called RegisterClass giving the class name
  119.    "MYBUTTON", szClass must be "MYBUTTON".
  120.  
  121. The function variables Info, Style, and Flags--which correspond
  122. to the pointers fnRWInfo, fnRWStyle, and fnFlags--are described
  123. in the following sections.
  124.  
  125.  
  126. Info function
  127. -------------
  128. Resource Workshop calls the Info function to retrieve
  129. information about the control class, including the string to
  130. add to the control menu and the bitmap to add to the tool
  131. palette. The function returns a memory handle that can be
  132. allocated by GlobalAlloc. This handle must refer to memory
  133. that contains a RWCTLINFO structure. Like ListClasses, the
  134. handle returned by Info is freed by Resource Workshop and
  135. should not be freed by the DLL. Resource Workshop calls this
  136. function once when it loads the DLL.
  137.  
  138. Syntax:
  139.  
  140.    HGLOBAL CALLBACK Info( void);
  141.  
  142. Parameters:
  143.  
  144.    None.
  145.  
  146. Structure:
  147.  
  148.    The RWCTLINFO structure, defined by a typedef in the file
  149.    CUSTCNTL.H, has two basic parts:
  150.  
  151.    - The first part has a fixed length and provides information
  152.      about the whole control class.
  153.  
  154.    - The second part is a variable-length array of fixed-length
  155.      records. Each record provides information about a
  156.      particular type or subclass of the control.
  157.  
  158.    /* general size definitions */
  159.    #define     CTLTYPES   12   /* number of control types   */
  160.    #define     CTLDESCR   22   /* size of control menu name */
  161.    #define     CTLCLASS   20   /* max size of class name    */
  162.    #define     CTLTITLE   94   /* max size of control text  */
  163.  
  164.     typedef struct {
  165.       UINT         wVersion;          // control version
  166.       UINT         wCtlTypes;         // control types
  167.       char         szClass[CTLCLASS]; // control class name
  168.       char         szTitle[CTLTITLE]; // control title
  169.       char         szReserved[10];    // reserved for future
  170.       RWCTLTYPE    Type[CTLTYPES];    // control type list
  171.     } RWCTLINFO;
  172.  
  173.     typedef RWCTLINFO *RWPCTLINFO;
  174.     typedef RWCTLINFO FAR *LPRWCTLINFO;
  175.  
  176.    wVersion    The version number of the custom control
  177.                library. The major version is in the high-
  178.                order byte and the minor version is in the
  179.                low-order byte. For example, version 1.02 is
  180.                0x0102. Resource Workshop doesn't use this.
  181.  
  182.    wCtlTypes   The number of control sub-types defined in the
  183.                Type array.
  184.  
  185.    szClass     The name of the class as registered with
  186.                Windows. This is duplicated from the
  187.                CTLCLASSLIST structure to retain upward
  188.                compatiblity with the Windows custom control
  189.                specificiation.
  190.  
  191.    szReserved  Space reserved for future expansion. Must be
  192.                cleared to null characters (0).
  193.  
  194.    Type        An array of sub-type description structures of
  195.                type RWCTLTYPE.
  196.  
  197.     /*
  198.      * RWCTLTYPE DATA STRUCTURE
  199.      *
  200.      * This data structure is returned by the control options
  201.      * function while inquiring about the capabilities of a
  202.      * particular control. Each control may contain various types
  203.      * (with predefined style bits) under one general class.
  204.      *
  205.      * The width and height fields provide the application with
  206.      * a suggested size. Use pixels or dialog units for the
  207.      * values in these fields. If you use pixels, turn on the
  208.      * most significant bit (MSB). If you use dialog units, turn
  209.      * off the MSB.
  210.      *
  211.      */
  212.  
  213.      typedef struct {
  214.        UINT         wType;               /* type style */
  215.        UINT         wWidth;              /* suggested width */
  216.        UINT         wHeight;             /* suggested height */
  217.        DWORD        dwStyle;             /* default style */
  218.        char         szDescr[CTLDESCR];   /* menu name */
  219.        HBITMAP      hToolBit;            // Toolbox bitmap
  220.        HCURSOR      hDropCurs;           // Drag and drop cursor
  221.      } RWCTLTYPE, FAR * LPRWCTLTYPE;
  222.  
  223.    wType        A user-defined value used to indicate the
  224.                 sub-type of the control. This value isn't
  225.                 used by Resource Workshop.
  226.  
  227.    wWidth       The default width for the control. Resource
  228.                 Workshop uses this value if, for example,
  229.                 the control is created by dragging the icon
  230.                 from the tool palette. wWidth is in dialog
  231.                 coordinates unless the most significant bit is
  232.                 set, in which case the value is in pixels. For
  233.                 example, a value of "32" is 32 in dialog
  234.                 coordinates, but the value "32 | 0x8000" is in
  235.                 pixels.
  236.  
  237.    wHeight      The default height for the control. Resource
  238.                 Workshop uses this value if, for example,
  239.                 the control is created by dragging the icon
  240.                 from the tool palette. wHeight is in dialog
  241.                 coordinates unless the most significant bit is
  242.                 set, in which case the value is in pixels. For
  243.                 example, a value of "32" is 32 in dialog
  244.                 coordinates, but the value "32 | 0x8000" is
  245.                 in pixels.
  246.  
  247.    wStyle       The default style Resource Workshop uses
  248.                 to create the Window. This is the key field
  249.                 that you use to distinguish one subtype
  250.                 from another.
  251.  
  252.    szDescr      The description of the control subtype.
  253.                 Resource Workshop uses the to text construct
  254.                 a menu item that the user can use to create an
  255.                 instance of your custom control.
  256.  
  257.    hToolBit     A handle to a bitmap which will be placed on
  258.                 the tool palette. Resource Workshop requires
  259.                 the bitmap be a 22x22 black and gray bitmap
  260.                 containing a 2-pixel border that is white on
  261.                 the top and left and black on the bottom and
  262.                 right. You can use the bitmaps contained in
  263.                 BITBTN.RES as templates.
  264.  
  265.    hDropCurs    A cursor to be used while dragging the control
  266.                 from the tool palette.
  267.  
  268.  
  269. Style function
  270. --------------
  271. The Style function makes it possible for you to edit your
  272. custom control. You must first create an appropriate dialog
  273. box in Resource Workshop and then implement a Boolean
  274. function that displays that dialog box. Resource Workshop
  275. calls this function whenever you initiate a request to edit
  276. the custom control. Resource Workshop passes the function a
  277. handle to the window that is the parent of the dialog, a
  278. handle to memory containing the RWCTLSTYLE structure, and
  279. two function variables for string conversion.
  280.  
  281. Return value:
  282.  
  283.     If the user changes any options for the control, this
  284.     function's return value is TRUE. If the user doesn't make
  285.     changes or if an error prevents changes, the return value
  286.     is FALSE.
  287.  
  288. Syntax:
  289.  
  290.     BOOL CALLBACK Style( HWND hWnd, HGLOBAL hCtlStyle,
  291.     LPFNSTRTOID lpfnStrToId, LPFNIDTOSTR lpfnIdToStr);
  292.  
  293. Parameters:
  294.  
  295.    hWnd         A handle to the parent window of the dialog
  296.                 box displayed by this function.
  297.  
  298.    hCtlStyle    A handle to global memory containing the
  299.                 RWCTLSTYLE structure to be edited.
  300.  
  301.    lpfnStrToId  A function variable that converts a string
  302.                 into a control ID for the wId field of
  303.                 RWCTLSTYLE. This lets the user enter the
  304.                 control ID using a constant identifier. This
  305.                 routine evaluates the string as an expression,
  306.                 returning the result. The ID can convert
  307.                 back into a string by calling lpfnIdToStr.
  308.  
  309.    lpfnIdToStr  A function variable that converts the control
  310.                 ID in the wId field of RWCTLSTYLE to a string
  311.                 for editing. The ID can be converted back into
  312.                 a word by calling lpfnStrToId. This function
  313.                 variable lets the user see the symbolic
  314.                 constant that represents the control ID
  315.                 instead of the word value.
  316.  
  317. Data structure:
  318.  
  319.     /*
  320.      * CONTROL-STYLE DATA STRUCTURE
  321.      *
  322.      * The class style function uses this data structure
  323.      * to set or reset various control attributes.
  324.      *
  325.      */
  326.  
  327.    typedef struct {
  328.      UINT         wX;                  // x origin of control
  329.      UINT         wY;                  // y origin of control
  330.      UINT         wCx;                 // width of control
  331.      UINT         wCy;                 // height of control
  332.      UINT         wId;                 // control child id
  333.      DWORD        dwStyle;             // control style
  334.      char         szClass[CTLCLASS];   // control class name
  335.      char         szTitle[CTLTITLE];   // control text
  336.      BYTE         CtlDataSize;         // control data size
  337.      BYTE         CtlData[ CTLDATALENGTH]; // control data
  338.    } RWCTLSTYLE;
  339.  
  340.     typedef RWCTLSTYLE *   PRWCTLSTYLE;
  341.     typedef RWCTLSTYLE FAR *   LPRWCTLSTYLE;
  342.  
  343.    wX          The horizontal (X) location of the control in
  344.                dialog coordinates.
  345.  
  346.    wY          The vertical (Y) location of the control in
  347.                dialog coordinates.
  348.  
  349.    wCx         The width of the control (dialog coordinates).
  350.  
  351.    wCy         The height of the control (dialog coordinates).
  352.  
  353.    wId          The control's ID value. This value must be
  354.                 converted to a string by calling lpfnIdToStr
  355.                 before being displayed for editing. It must
  356.                 be converted back into a word for storage by
  357.                 calling lpfnStrToId after editing.
  358.  
  359.    dwStyle      The style flags of the control.
  360.  
  361.    szClass      The class name of the control.
  362.  
  363.    szTitle      The title of the control.
  364.  
  365.    CtlDataSize  Windows lets controls in a resource file
  366.                 have up to 255 bytes of control-defined data.
  367.                 This field indicates how much of that space is
  368.                 being used by the control. The data is stored
  369.                 in CtlData.
  370.  
  371.    CtlData      This field holds up to 255 bytes of
  372.                 control-specific data. The amount used must
  373.                 be recorded in the CtlDataSize field. The use
  374.                 of this data area is user-defined.
  375.  
  376. When you save your project, Resource Workshop saves the CtlData
  377. array into the .RC or .RES file.
  378.  
  379. To enable a custom control to access this array from within
  380. your program at run time, lParam of the WM_CREATE message
  381. points to a CREATESTRUCT data structure. The CREATESTRUCT
  382. structure contains a field, lpCreateParams, that is a pointer
  383. to the extra data you stored in the CtlData array. If the
  384. pointer is NULL, there is no CtlData.
  385.  
  386. The CtlDataSize variable isn't available to your program. To
  387. make the size data accessible to your program, the CtlData
  388. array should either contain a fixed amount of data, or its
  389. first byte should contain the length of the data.
  390.  
  391. The Style function first converts the ID to a string by
  392. passing the numerical ID value to LPFNIDTOSTR. The Style
  393. function then displays the string in the dialog box.
  394.  
  395. If the user changes the string returned by LPFNIDTOSTR, the
  396. Style function verifies the string by passing it to
  397. LPFNSTRTOID, which determines if the string is a valid
  398. constant expression. If LPFNSTRTOID returns a zero in the
  399. LOWORD, the ID is illegal and is displayed in the dialog box,
  400. so the user can change it to a valid ID. If LPFNSTRTOID is
  401. successful, it returns a nonzero value in the LOWORD and the
  402. ID in the HIWORD.
  403.  
  404.  
  405. Flags function
  406. --------------
  407. Resource Workshop uses the Flags function to translate the
  408. style of a control into text. Resource Workshop inserts the
  409. text into the .RC file being edited. The function must only
  410. convert the values unique to the control. For example, if
  411. you were creating a Flags function for the Windows button
  412. class, you would only examine the lower sixteen bits of Flags
  413. and translate them into one of the bs_XXXX constants.
  414.  
  415. Return value:
  416.  
  417.     Returns the number of bytes copied into the destination
  418.     string. Returns 0 if the Flags word is not valid or the
  419.     string exceeds MaxString in length.
  420.  
  421. Syntax:
  422.  
  423.     UINT CALLBACK Flags(DWORD dwFlags, LPSTR lpStyle, UINT
  424.     wMaxString);
  425.  
  426. Parameters:
  427.  
  428.    dwFlags       The control style to be translated into text.
  429.                  This field is derived from the dwStyle
  430.                  field of the RWCTLSTYLE structure passed to
  431.                  the Style function variable.
  432.  
  433.    lpStyle       The location to write the translated
  434.                  text.
  435.  
  436.    wMaxString    The maximum number of bytes the Flags function
  437.                  can write into Style.
  438.  
  439.  
  440. =============================================================
  441. USING PASCAL TO CREATE CUSTOM CONTROLS
  442. =============================================================
  443.  
  444. ListClasses function
  445. --------------------
  446. ListClasses is a programmer-implemented function that passes
  447. information about the custom control classes back to
  448. Resource Workshop. Exporting ListClasses marks your DLL as
  449. supporting this custom control specification.
  450.  
  451. If ListClasses is present in the DLL, Resource Workshop
  452. calls the function, passing information about itself along
  453. with two utility function variables used in editing the
  454. custom control.
  455.  
  456. ListClasses should return a handle to global memory allocated
  457. by calling GlobalAlloc. The memory referenced by this handle
  458. holds a record of type TCtlClassList, which describes the
  459. controls in the library. TCtlClassList is described later in
  460. this section. The handle is freed by Resource Workshop and
  461. should not be freed by the DLL.
  462.  
  463. Syntax:
  464.  
  465.     function ListClasses(AppName: PChar; Version: Word;
  466.       Load: TLoad; Edit: TEdit): THandle; export;
  467.  
  468. Return value:
  469.  
  470.     Returns a handle to global memory containing a record of
  471.     type TCtlClassList.
  472.  
  473. Parameters:
  474.  
  475.    AppName     The class name of the main window of the
  476.                calling application. This value can be used
  477.                by the custom control to determine if it is
  478.                running under a resource editor. If AppName is
  479.                'rwswnd', the calling application is Resource
  480.                Workshop.
  481.  
  482.    Version     The version number of the calling application.
  483.                The major version is in the high-order byte
  484.                and the minor version in the low-order byte.
  485.                For example, version 1.02 is $0102.
  486.  
  487.    Load        A function variable that custom controls can
  488.                use to obtain the handle of a resource in the
  489.                project being edited by the calling
  490.                application (the equivalent of the Windows API
  491.                function LoadResource). The function takes two
  492.                parameters, a resource type name and a
  493.                resource name. The custom control is
  494.                responsible for freeing the global handle (if
  495.                any) returned by this function.
  496.  
  497.    Edit        A function variable that custom controls can
  498.                use to start a resource editor for any
  499.                resource in the project being edited by
  500.                Resource Workshop. The function takes two
  501.                parameters, a resource type name and a
  502.                resource name.
  503.  
  504. Return value records:
  505.  
  506.     PCtlClassList = ^TCtlClassList;
  507.     TCtlClassList = record
  508.       nClasses: Integer;           { Number of classes in list }
  509.       Classes: array[0..0] of TRWCtlClass;     { Class list }
  510.     end;
  511.  
  512.     TCtlClassList contains a variable number of TRWCtlClass
  513.     records, the number of which is determined by the nClasses
  514.     field.
  515.  
  516.     PRWCtlClass = ^TRWCtlClass;
  517.     TRWCtlClass = record
  518.       fnInfo:  TFnInfo;                       { Info function }
  519.       fnStyle: TFnStyle;                      { Style function }
  520.       fnFlags: TFnFlags;                      { Flags function }
  521.       szClass: array[0..ctlClass-1] of Char;  { Class name }
  522.     end;
  523.  
  524.     Each control class in the DLL must have a corresponding
  525.     TRWCtlClass record in the TCtlClassList. The szClass field
  526.     contains the name with which the class was registered. For
  527.     example, if you called RegisterClass giving the class name as
  528.     'MYBUTTON', szClass must be 'MYBUTTON'.
  529.  
  530. The function variables Info, Style, and Flags--which correspond
  531. to the pointers TFnInfo, TFnStyle, and TFnFlags--are described in
  532. the following sections.
  533.  
  534.  
  535. Info function
  536. -------------
  537. The Info function is called by Resource Workshop to retrieve
  538. information about the control class, including the string to
  539. add to the control menu and the bitmap to add to the tool
  540. palette. The function returns a memory handle that can be
  541. allocated by GlobalAlloc. This handle must refer to memory
  542. that contains a TRWCtlInfo record. Like ListClasses, the
  543. handle returned by Info is freed by Resource Workshop and
  544. should not be freed by the DLL. This function is called once
  545. by Resource Workshop upon loading the DLL.
  546.  
  547. Syntax:
  548.  
  549.     function Info: Handle; export;
  550.  
  551. Return value:
  552.  
  553.     Returns a handle to global memory containing a record of
  554.     type TRWCtlInfo.
  555.  
  556. Parameters:
  557.  
  558.     None.
  559.  
  560. Return value record:
  561.  
  562.    TRWCtlInfo has two parts:
  563.  
  564.     - A fixed-length part that provides information about the
  565.       control class in general.
  566.  
  567.     - A variable-length array of records, with each record
  568.       providing information about a particular type or
  569.       subclass of the control.
  570.  
  571.    Each control class can include several control types. For
  572.    example, Windows provides a BUTTON class that includes push
  573.    buttons, radio buttons, and check boxes. This variety can be
  574.    duplicated by your classes by providing two or more
  575.    TRWCtlType records in the TRWCtlInfo record.
  576.  
  577.    The following is the declaration of TRWCtlInfo:
  578.  
  579.     PRWCtlInfo = ^TRWCtlInfo;
  580.     TRWCtlInfo = record
  581.       wVersion:   Word;          { control version }
  582.       wCtlTypes:  Word;          { control types }
  583.       szClass:    array[0..ctlClass-1] of Char;
  584.                                  { control class name }
  585.       szTitle:    array[0..ctlTitle-1] of Char;
  586.                                  { control title }
  587.       szReserved: array[0..9] of Char;
  588.                                  { reserved for future use }
  589.       ctType:     array[0..ctlTypes] of TRWCtlType;
  590.                                  { control type list }
  591.     end;
  592.  
  593.    wVersion     The version number of the custom control
  594.                 library. The major version is in the
  595.                 high-order byte and the minor version in the
  596.                 low-order byte. For example, version 1.02 is
  597.                 $0102. This field is not used by Resource
  598.                 Workshop.
  599.  
  600.    wCtlTypes    The number of control sub-types defined in the
  601.                 ctType array.
  602.  
  603.    szClass      The name of the class as registered with
  604.                 Windows. This is duplicated from the
  605.                 TCtlClassList record to retain upward
  606.                 compatiblity with the Windows custom control
  607.                 specificiation.
  608.  
  609.    szReserved   Space reserved for future expansion. Must be
  610.                 cleared to null characters (#0).
  611.  
  612.    ctType       An array of sub-type description records of
  613.                 type TRWCtlType.
  614.  
  615.    The following is the declaration of TRWCtlType:
  616.  
  617.     PRWCtlType = ^TRWCtlType;
  618.     TRWCtlType = record
  619.       wType:   Word;                         { type style }
  620.       wWidth:  Word;                         { suggested width }
  621.       wHeight: Word;                         { suggested height }
  622.       dwStyle: LongInt;                      { default style }
  623.       szDescr: array[0..ctlDescr-1] of Char; { menu name }
  624.       hToolBit:  HBitmap;                    { toolbox bitmap }
  625.       hDropCurs: HCursor;              { drag and drop cursor }
  626.     end;
  627.  
  628.    wType       A user-defined value used to indicate the
  629.                sub-type of the control. This value is not
  630.                used by Resource Workshop.
  631.  
  632.    wWidth      The default width for the control. Resource
  633.                Workshop will use this value if, for example,
  634.                the control is created by dragging the icon
  635.                from the tool palette. wWidth is in dialog
  636.                coordinates unless the most significant bit is
  637.                set, in which case the value is in pixels. For
  638.                example, a value of "32" is 32 in dialog
  639.                coordinates, but the value "32 or $8000" is in
  640.                pixels.
  641.  
  642.    wHeight     The default height for the control. Resource
  643.                Workshop will use this value if, for example,
  644.                the control is created by dragging the icon
  645.                from the tool palette. wHeight is in dialog
  646.                coordinates unless the most significant bit is
  647.                set, in which case the value is in pixels. For
  648.                example, a value of "32" is 32 in dialog
  649.                coordinates, but the value "32 or $8000" is in
  650.                pixels.
  651.  
  652.    wStyle      The default style Resource Workshop will use
  653.                to create the Window. This is the key field
  654.                that you will use to distinguish one subtype
  655.                from another.
  656.  
  657.    szDescr     The description of the control subtype. This
  658.                text is used by Resource Workshop to construct
  659.                a menu item that the user can use to create an
  660.                instance of your custom control.
  661.  
  662.    hToolBit    A handle to a bitmap which will be placed on
  663.                the tool palette. Resource Workshop requires
  664.                the bitmap be a 22x22 black and gray bitmap
  665.                containing a 2-pixel border that is white on
  666.                the top and left and black on the bottom and
  667.                right. You can use the bitmaps contained in
  668.                BITBTN.RES as templates.
  669.  
  670.    hDropCurs   A cursor to be used while dragging the control
  671.                from the tool palette.
  672.  
  673.  
  674. Style function
  675. --------------
  676. The Style function makes it possible for you to edit your
  677. custom control. You must first create an appropriate dialog
  678. box in Resource Workshop and then implement a Boolean
  679. function that displays that dialog box. Resource Workshop
  680. calls this function whenever you initiate a request to edit
  681. the custom control. Resource Workshop passes the function a
  682. handle to the window that is the parent of the dialog, a
  683. handle to memory containing the TRWCtlStyle record, and
  684. two function variables for string conversion.
  685.  
  686. Return value:
  687.  
  688.    The function must return true if the TRWCtlSytle record
  689.    has been modified; otherwise, it must return false.
  690.  
  691. Syntax:
  692.  
  693.     function Style(Window: HWnd; CtlStyle: THandle; StrToId:
  694.       TStrToId; IdToStr: TIdToStr): Bool; export;
  695.  
  696. Parameters:
  697.  
  698.    Window      A handle to the parent window of the dialog
  699.                box displayed by this function.
  700.  
  701.    CtlStyle    A handle to global memory containing the
  702.                TRWCtlStyle record to be edited.
  703.  
  704.    StrToId     A function variable that converts a string
  705.                into a control ID for the wId field of
  706.                TRWCtlStyle. This allows the user to enter the
  707.                control ID using a constant identifier. This
  708.                routine evaluates the string as an expression,
  709.                returning the result. The ID can be converted
  710.                back into a string by calling IdToStr.
  711.  
  712.    IdToStr     A function variable that converts the control
  713.                ID in the wId field of TRWCtlStyle to a string
  714.                for editing. The ID can be converted back into
  715.                a word by calling StrToId. This function
  716.                variable allows the user to see the symbolic
  717.                constant that represents the control ID
  718.                instead of the word value.
  719.  
  720. CtlStyle record:
  721.  
  722.    The following is the record type referenced by the CtlStyle
  723.    memory handle:
  724.  
  725.       PRWCtlStyle = ^TRWCtlStyle;
  726.       TRWCtlStyle = record
  727.         wX:   Word;               { x origin of control }
  728.         wY:   Word;               { y origin of control }
  729.         wCx:  Word;               { width of control }
  730.         wCy:  Word;               { height of control }
  731.         wId:  Word;               { control child id }
  732.         dwStyle: LongInt;         { control style }
  733.         szClass: array[0..ctlClass-1] of Char;
  734.                                   { name of control class }
  735.         szTitle: array[0..ctlTitle-1] of Char;
  736.                                   { control text }
  737.         CtlDataSize: Byte;        { control data size }
  738.         CtlData: array[0..ctlDataLength-1] of Char;
  739.                                   { control data }
  740.       end;
  741.  
  742.      wX          The horizontal (X) location of the control in
  743.                  dialog coordinates.
  744.  
  745.      wY          The vertical (Y) location of the control in
  746.                  dialog coordinates.
  747.  
  748.      wCx         The width of the control in dialog
  749.                  coordinates.
  750.  
  751.      wCy         The height of the control in dialog
  752.                  coordinates.
  753.  
  754.      wId         The control's ID value. This value must be
  755.                  converted to a string by calling IdToStr
  756.                  before being displayed for editing. It must
  757.                  be converted back into a word for storage by
  758.                  calling StrToId after editing.
  759.  
  760.      dwStyle     The style flags of the control.
  761.  
  762.      szClass     The class name of the control.
  763.  
  764.      szTitle     The title of the control.
  765.  
  766.     CtlDataSize  Windows allows controls in a resource file
  767.                  to have up to 255 bytes of control-defined
  768.                  data. This field indicates how much of that
  769.                  space is being used by the control. The data
  770.                  is stored in CtlData.
  771.  
  772.      CtlData     This field holds up to 255 bytes of
  773.                  control-specific data. The amount used must
  774.                  be recorded in the CtlDataSize field. The use
  775.                  of this data area is user-defined.
  776.  
  777. When you save your project, Resource Workshop saves the
  778. CtlData array into the .RC or .RES file.
  779.  
  780. To enable a custom control to access this array from within
  781. your program at run time, lParam of the WM_CREATE message
  782. points to a CREATESTRUCT data structure. The CREATESTRUCT
  783. structure contains a field, lpCreateParams, that is a pointer
  784. to the extra data you stored in the CtlData array. If the
  785. pointer is nil, there is no CtlData.
  786.  
  787. The CtlDataSize variable is not available to your program.
  788. To make the size data accessible to your program, the
  789. CtlData array should either contain a fixed amount of data,
  790. or its first byte should contain the length of the data.
  791.  
  792. The Style function first converts the ID to a string by
  793. passing the numerical ID value to IdToStr. The Style
  794. function then displays the string in the dialog box.
  795.  
  796. If the user changes the string that's returned by IdToStr,
  797. the Style function verifies the string by passing it to
  798. StrToId, which determines if the string is a valid constant
  799. expression. If StrToId returns a zero in the low word, the
  800. ID is illegal and is displayed in the dialog box so the user
  801. can change it to a valid ID. If StrToId is successful, it
  802. returns a nonzero value in the low word and the ID in the
  803. high word.
  804.  
  805.  
  806. Flags function
  807. --------------
  808. The Flags function is used by Resource Workshop to translate
  809. the style of a control into text. Resource Workshop inserts
  810. the text into the .RC file being edited. The function must
  811. only convert the values unique to the control. For example,
  812. if you were creating a Flags function for the Windows button
  813. class, you would only examine the lower sixteen bits of Flags
  814. and translate them into one of the bs_XXXX constants.
  815.  
  816. Return value:
  817.  
  818.     Returns the number of bytes copied into the destination
  819.     string. Returns 0 if the Flags word is not valid or the
  820.     string exceeds MaxString in length.
  821.  
  822. Syntax:
  823.  
  824.     function Flags(Flags: LongInt; Style: PChar; MaxString:
  825.       Word): Word;
  826.  
  827.   Parameters:
  828.  
  829.    Flags       The style of the control to be translated into
  830.                text. This field is derived from the dwStyle
  831.                field of the TRWCtlStyle record passed to the
  832.                Style function variable.
  833.  
  834.    Style       The location to write the translated text.
  835.  
  836.    MaxString   The maximum number of bytes the Flags function
  837.                can write into Style.
  838.  
  839.            ========= END OF FILE CUSTCNTL.RW =========
  840.