home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / genvbx / generic.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-10  |  7.0 KB  |  243 lines

  1. //-------------------------------------------------------
  2. // GENERIC.H
  3. //-------------------------------------------------------
  4. // Contains code for Generic VBX control.
  5. //
  6. // Use the following files as templates for building your
  7. // own VBX control:
  8. //
  9. // - GENERIC.C
  10. // - GENERIC.H (this file)
  11. // - GENERIC.DEF
  12. // - GENERIC.RC 
  13. //-------------------------------------------------------
  14.  
  15. //------------------------------------------------------
  16. // Resource Information
  17. //------------------------------------------------------
  18. // Toolbox bitmap resource IDs numbers.
  19. //------------------------------------------------------
  20. #define IDBMP_UP         8000
  21. #define IDBMP_DOWN       8001
  22. #define IDBMP_UPMONO     8003
  23. #define IDBMP_UPEGA      8006
  24.  
  25. //------------------------------------------------------
  26. // Change these for each new VBX file
  27. //------------------------------------------------------
  28. #define VBX_COMPANYNAME      "Company Name\0"
  29. #define VBX_FILEDESCRIPTION  "Generic Control\0"
  30. #define VBX_INTERNALNAME     "GENERIC\0"
  31. #define VBX_LEGALCOPYRIGHT   "Copyright Company Name\0"
  32. #define VBX_LEGALTRADEMARKS  "Trademarks\0"
  33. #define VBX_ORIGINALFILENAME "GENERIC.VBX\0"
  34. #define VBX_PRODUCTNAME      "Generic VBX Control\0"
  35.  
  36.  
  37. //------------------------------------------------------
  38. // Update these fields for each build.
  39. //------------------------------------------------------
  40. #define VBX_VERSION         3,00,0,00
  41. #define VBX_VERSION_STR     "3.00.000\0"
  42.  
  43.  
  44. #ifndef RC_INVOKED
  45. //------------------------------------------------------
  46. // Control Procedure
  47. //------------------------------------------------------
  48. LONG FAR PASCAL _export GenericCtlProc(HCTL, HWND, USHORT,
  49.                                        USHORT, LONG);
  50.  
  51.  
  52. //------------------------------------------------------
  53. // The structure of the control.
  54. //------------------------------------------------------
  55. typedef struct tagGENERIC
  56.     {
  57.     BOOL dummy;
  58.     
  59.     // TODO: Define variables that correspond to the
  60.     //       custom properties
  61.     //
  62.     // Example:
  63.     // BOOL MyProperty;
  64.     // LONG HerProperty;
  65.  
  66.  
  67.         
  68.     } GENERIC;
  69.  
  70.  
  71.  
  72. typedef GENERIC FAR * LPGENERIC;
  73.  
  74. // A macro to get a pointer to the structure.
  75. #define pGENERIC(hctl)  ((LPGENERIC)VBDerefControl(hctl))
  76.  
  77. // Macro to get offset of a field within a structure.
  78. #define OFFSETIN(struc, field) ((USHORT)&(((struc *)0)->field))
  79.  
  80.  
  81. //------------------------------------------------------
  82. // Property Information Structures
  83. //------------------------------------------------------
  84. //
  85. // TODO: Define PROPINFO structure for each custom property 
  86. //
  87. // Example:
  88. //
  89. //PROPINFO Property_MyProperty =
  90. //    {
  91. //    "MyProperty",
  92. //    DT_SHORT | PF_fGetData | PF_fSetMsg | PF_fSaveData,
  93. //    OFFSETIN(GENERIC, MyProperty),
  94. //    0, 0, NULL, 0
  95. //    };
  96.  
  97.  
  98.  
  99. //-------------------------------------------------------
  100. // Property Information Table
  101. //-------------------------------------------------------
  102. PPROPINFO Generic_Properties[] =
  103.     {
  104.     PPROPINFO_STD_CTLNAME,
  105.     PPROPINFO_STD_INDEX,
  106.     PPROPINFO_STD_BACKCOLOR,
  107.     PPROPINFO_STD_LEFT,
  108.     PPROPINFO_STD_TOP,
  109.     PPROPINFO_STD_WIDTH,
  110.     PPROPINFO_STD_HEIGHT,
  111.     PPROPINFO_STD_VISIBLE,
  112.     PPROPINFO_STD_PARENT,
  113.     PPROPINFO_STD_DRAGMODE,
  114.     PPROPINFO_STD_DRAGICON,
  115.     PPROPINFO_STD_TAG,
  116.     PPROPINFO_STD_HWND,
  117.  
  118.     // TODO: Specify addresses of properties structures
  119.     //
  120.     // Example: 
  121.     // &Property_MyProperty,    // Custom
  122.     // &Property_HerProperty,   // Custom
  123.     // PPROPINFO_STD_CAPTION,   // Standard
  124.     
  125.     
  126.     NULL
  127.     };
  128.  
  129.  
  130. //-------------------------------------------------------
  131. // Property List Constants
  132. //-------------------------------------------------------
  133. #define IPROP_GENERIC_CTLNAME             0
  134. #define IPROP_GENERIC_INDEX               1
  135. #define IPROP_GENERIC_BACKCOLOR           2
  136. #define IPROP_GENERIC_LEFT                3
  137. #define IPROP_GENERIC_TOP                 4
  138. #define IPROP_GENERIC_WIDTH               5
  139. #define IPROP_GENERIC_HEIGHT              6
  140. #define IPROP_GENERIC_VISIBLE             7
  141. #define IPROP_GENERIC_PARENT              8
  142. #define IPROP_GENERIC_DRAGMODE            9
  143. #define IPROP_GENERIC_DRAGICON           10
  144. #define IPROP_GENERIC_TAG                11
  145. #define IPROP_GENERIC_HWND               12
  146.  
  147. // TODO: Define consecutive ID's of more properties
  148. //
  149. // Example: 
  150. // #define IPROP_GENERIC_MYPROPERTY      13
  151. // #define IPROP_GENERIC_HERPROPERTY     14
  152. // #define IPROP_GENERIC_CAPTION         15
  153.  
  154.  
  155. //------------------------------------------------------
  156. // Event Information Structures
  157. //------------------------------------------------------
  158. //
  159. // TODO: Define EVENTINFO structure for each custom event
  160. //
  161. // Example:
  162. //
  163. // EVENTINFO Event_MyEvent =
  164. //      {
  165. //      "MyEvent",
  166. //      0,
  167. //      0,
  168. //      NULL,
  169. //      NULL
  170. //      };
  171.  
  172.  
  173.  
  174. //-------------------------------------------------------
  175. // Event Information Table
  176. //-------------------------------------------------------
  177. PEVENTINFO Generic_Events[] =
  178.     {
  179.     PEVENTINFO_STD_CLICK,
  180.     PEVENTINFO_STD_DRAGDROP,
  181.     PEVENTINFO_STD_DRAGOVER,
  182.  
  183.     // TODO: Specify addresses of events structures
  184.     //
  185.     // Example: 
  186.     // &Event_MyEvent,            // Custom
  187.     // &Event_HerEvent,           // Custom
  188.     // PEVENTINFO_STD_DBLCLICK,   // Standard
  189.  
  190.  
  191.  
  192.     NULL
  193.     };
  194.  
  195.  
  196.  
  197. //-------------------------------------------------------
  198. // Event List Constants
  199. //-------------------------------------------------------
  200. #define IEVENT_GENERIC_CLICK            0
  201. #define IEVENT_GENERIC_DRAGDROP         1
  202. #define IEVENT_GENERIC_DRAGOVER         2
  203.  
  204. // TODO: Define consecutive ID's of more events
  205. //
  206. // Example: 
  207. // #define IEVENT_GENERIC_MYEVENT       3
  208. // #define IEVENT_GENERIC_HEREVENT      4
  209. // #define IEVENT_GENERIC_DBLCLICK      5
  210.  
  211.  
  212.  
  213.  
  214.  
  215. //------------------------------------------------------
  216. // Model struct
  217. //------------------------------------------------------
  218. // Define the control model (using the event and property 
  219. // structures).
  220. //------------------------------------------------------
  221. MODEL modelGeneric =
  222.     {
  223.     VB_VERSION,               // VB version being used
  224.     0,                        // MODEL flags
  225.     (PCTLPROC)GenericCtlProc, // Control procedure
  226.     CS_VREDRAW | CS_HREDRAW,  // Class style
  227.     WS_BORDER,                // Default Windows style
  228.     sizeof(GENERIC),          // Size of structure
  229.     IDBMP_UP,                 // Palette bitmap ID
  230.     "Generic",                // Default control name
  231.     "GENERIC",                // Visual Basic class name
  232.     NULL,                     // Parent class name
  233.     Generic_Properties,       // Property information table
  234.     Generic_Events,           // Event information table
  235.     IPROP_GENERIC_BACKCOLOR,  // Default property
  236.     IEVENT_GENERIC_CLICK,     // Default event
  237.     (BYTE)-1                  // Value of control
  238.     };
  239.  
  240. #endif    // RC_INVOKED
  241.  
  242. //------------------------------------------------------
  243.