home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch35 / myclock / myclock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-10  |  8.7 KB  |  332 lines

  1. //-------------------------------------------------------
  2. // MYCLOCK.H
  3. //-------------------------------------------------------
  4. // Contains code for Myclock VBX control.
  5. //
  6. // Use the following files as templates for building your
  7. // own VBX control:
  8. //
  9. // - MYCLOCK.C
  10. // - MYCLOCK.H (this file)
  11. // - MYCLOCK.DEF
  12. // - MYCLOCK.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  "Myclock Control\0"
  30. #define VBX_INTERNALNAME     "MYCLOCK\0"
  31. #define VBX_LEGALCOPYRIGHT   "Copyright Company Name\0"
  32. #define VBX_LEGALTRADEMARKS  "Trademarks\0"
  33. #define VBX_ORIGINALFILENAME "MYCLOCK.VBX\0"
  34. #define VBX_PRODUCTNAME      "Myclock 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 MyclockCtlProc(HCTL, HWND, USHORT,
  49.                                        USHORT, LONG);
  50.  
  51.  
  52. //------------------------------------------------------
  53. // The structure of the control.
  54. //------------------------------------------------------
  55. typedef struct tagMYCLOCK
  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.     // MY CODE STARTS HERE
  68.     //////////////////////
  69.     
  70.     // The UpdateInterval custom property.
  71.     SHORT UpdateInterval;
  72.     
  73.     ////////////////////
  74.     // MY CODE ENDS HERE
  75.     ////////////////////
  76.  
  77.         
  78.     } MYCLOCK;
  79.  
  80.  
  81. typedef MYCLOCK FAR * LPMYCLOCK;
  82.  
  83. // A macro to get a pointer to the structure.
  84. #define pMYCLOCK(hctl)  ((LPMYCLOCK)VBDerefControl(hctl))
  85.  
  86. // Macro to get offset of a field within a structure.
  87. #define OFFSETIN(struc, field) ((USHORT)&(((struc *)0)->field))
  88.  
  89.  
  90. //------------------------------------------------------
  91. // Property Information Structures
  92. //------------------------------------------------------
  93. //
  94. // TODO: Define PROPINFO structure for each custom property 
  95. //
  96. // Examples:
  97. //
  98. //PROPINFO Property_MyProperty =
  99. //    {
  100. //    "MyProperty",
  101. //    DT_SHORT | PF_fGetData | PF_fSetMsg | PF_fSaveData,
  102. //    OFFSETIN(MYCLOCK, MyProperty),
  103. //    0, 0, NULL, 0
  104. //    };
  105.  
  106.  
  107. //////////////////////
  108. // MY CODE STARTS HERE
  109. //////////////////////
  110.     
  111. PROPINFO Property_UpdateInterval =
  112.     {
  113.     "UpdateInterval",
  114.     DT_SHORT | PF_fGetData | PF_fSetMsg | PF_fSaveData,
  115.     OFFSETIN(MYCLOCK, UpdateInterval),
  116.     0, 0, NULL, 0
  117.     };
  118.  
  119. ////////////////////
  120. // MY CODE ENDS HERE
  121. ////////////////////
  122.  
  123.  
  124.  
  125.  
  126. //-------------------------------------------------------
  127. // Property Information Table
  128. //-------------------------------------------------------
  129. PPROPINFO Myclock_Properties[] =
  130.     {
  131.     PPROPINFO_STD_CTLNAME,
  132.     PPROPINFO_STD_INDEX,
  133.     PPROPINFO_STD_BACKCOLOR,
  134.     PPROPINFO_STD_LEFT,
  135.     PPROPINFO_STD_TOP,
  136.     PPROPINFO_STD_WIDTH,
  137.     PPROPINFO_STD_HEIGHT,
  138.     PPROPINFO_STD_VISIBLE,
  139.     PPROPINFO_STD_PARENT,
  140.     PPROPINFO_STD_DRAGMODE,
  141.     PPROPINFO_STD_DRAGICON,
  142.     PPROPINFO_STD_TAG,
  143.     PPROPINFO_STD_HWND,
  144.  
  145.     // TODO: Specify addresses of properties structures
  146.     //
  147.     // Example: 
  148.     // &Property_MyProperty,    // Custom
  149.     // &Property_HerProperty,   // Custom
  150.     // PPROPINFO_STD_CAPTION,   // Standard
  151.     
  152.     //////////////////////
  153.     // MY CODE STARTS HERE
  154.     //////////////////////
  155.     
  156.     PPROPINFO_STD_FORECOLOR,
  157.     
  158.     &Property_UpdateInterval,
  159.  
  160.     ////////////////////
  161.     // MY CODE ENDS HERE
  162.     ////////////////////    
  163.  
  164.  
  165.     NULL
  166.     };
  167.  
  168.  
  169. //-------------------------------------------------------
  170. // Property List Constants
  171. //-------------------------------------------------------
  172. #define IPROP_MYCLOCK_CTLNAME             0
  173. #define IPROP_MYCLOCK_INDEX               1
  174. #define IPROP_MYCLOCK_BACKCOLOR           2
  175. #define IPROP_MYCLOCK_LEFT                3
  176. #define IPROP_MYCLOCK_TOP                 4
  177. #define IPROP_MYCLOCK_WIDTH               5
  178. #define IPROP_MYCLOCK_HEIGHT              6
  179. #define IPROP_MYCLOCK_VISIBLE             7
  180. #define IPROP_MYCLOCK_PARENT              8
  181. #define IPROP_MYCLOCK_DRAGMODE            9
  182. #define IPROP_MYCLOCK_DRAGICON           10
  183. #define IPROP_MYCLOCK_TAG                11
  184. #define IPROP_MYCLOCK_HWND               12
  185.  
  186. // TODO: Define consecutive ID's of more properties
  187. //
  188. // Example: 
  189. // #define IPROP_MYCLOCK_MYPROPERTY      13
  190. // #define IPROP_MYCLOCK_HERPROPERTY     14
  191. // #define IPROP_MYCLOCK_CAPTION         15
  192.  
  193. //////////////////////
  194. // MY CODE STARTS HERE
  195. //////////////////////
  196.  
  197. #define IPROP_MYCLOCK_FORECOLOR          13
  198.  
  199. #define IPROP_MYCLOCK_UPDATEINTERVAL     14
  200.  
  201. ////////////////////
  202. // MY CODE ENDS HERE
  203. ////////////////////
  204.  
  205.  
  206.  
  207. //------------------------------------------------------
  208. // Event Information Structures
  209. //------------------------------------------------------
  210. //
  211. // TODO: Define EVENTINFO structure for each custom event
  212. //
  213. // Example:
  214. //
  215. // EVENTINFO Event_MyEvent =
  216. //      {
  217. //      "MyEvent",
  218. //      0,
  219. //      0,
  220. //      NULL,
  221. //      NULL
  222. //      };
  223.  
  224. //////////////////////
  225. // MY CODE STARTS HERE
  226. //////////////////////
  227.  
  228. EVENTINFO Event_NewMinute =
  229.      {
  230.      "NewMinute",
  231.      0,
  232.      0,
  233.      NULL,
  234.      NULL
  235.      };
  236.  
  237. ////////////////////
  238. // MY CODE ENDS HERE
  239. ////////////////////
  240.  
  241.  
  242.  
  243. //-------------------------------------------------------
  244. // Event Information Table
  245. //-------------------------------------------------------
  246. PEVENTINFO Myclock_Events[] =
  247.     {
  248.     PEVENTINFO_STD_CLICK,
  249.     PEVENTINFO_STD_DRAGDROP,
  250.     PEVENTINFO_STD_DRAGOVER,
  251.  
  252.     // TODO: Specify addresses of events structures
  253.     //
  254.     // Example: 
  255.     // &Event_MyEvent,            // Custom
  256.     // &Event_HerEvent,           // Custom
  257.     // PEVENTINFO_STD_DBLCLICK,   // Standard
  258.  
  259.     //////////////////////
  260.     // MY CODE STARTS HERE
  261.     //////////////////////
  262.  
  263.     PEVENTINFO_STD_DBLCLICK,
  264.  
  265.     &Event_NewMinute, 
  266.  
  267.     ////////////////////
  268.     // MY CODE ENDS HERE
  269.     ////////////////////
  270.  
  271.     NULL
  272.     };
  273.  
  274.  
  275.  
  276. //-------------------------------------------------------
  277. // Event List Constants
  278. //-------------------------------------------------------
  279. #define IEVENT_MYCLOCK_CLICK            0
  280. #define IEVENT_MYCLOCK_DRAGDROP         1
  281. #define IEVENT_MYCLOCK_DRAGOVER         2
  282.  
  283. // TODO: Define consecutive ID's of more events
  284. //
  285. // Example: 
  286. // #define IEVENT_MYCLOCK_MYEVENT       3
  287. // #define IEVENT_MYCLOCK_HEREVENT      4
  288. // #define IEVENT_MYCLOCK_DBLCLICK      5
  289.  
  290. //////////////////////
  291. // MY CODE STARTS HERE
  292. //////////////////////
  293.  
  294. #define IEVENT_MYCLOCK_DBLCLICK         3
  295.  
  296. #define IEVENT_MYCLOCK_NEWMINUTE        4
  297.  
  298. ////////////////////
  299. // MY CODE ENDS HERE
  300. ////////////////////
  301.  
  302.  
  303.  
  304. //------------------------------------------------------
  305. // Model struct
  306. //------------------------------------------------------
  307. // Define the control model (using the event and property 
  308. // structures).
  309. //------------------------------------------------------
  310. MODEL modelMyclock =
  311.     {
  312.     VB_VERSION,               // VB version being used
  313.     0,                        // MODEL flags
  314.     (PCTLPROC)MyclockCtlProc, // Control procedure
  315.     CS_VREDRAW | CS_HREDRAW,  // Class style
  316.     WS_BORDER,                // Default Windows style
  317.     sizeof(MYCLOCK),          // Size of structure
  318.     IDBMP_UP,                 // Palette bitmap ID
  319.     "Myclock",                // Default control name
  320.     "MYCLOCK",                // Visual Basic class name
  321.     NULL,                     // Parent class name
  322.     Myclock_Properties,       // Property information table
  323.     Myclock_Events,           // Event information table
  324.     IPROP_MYCLOCK_BACKCOLOR,  // Default property
  325.     IEVENT_MYCLOCK_CLICK,     // Default event
  326.     (BYTE)-1                  // Value of control
  327.     };
  328.  
  329. #endif    // RC_INVOKED
  330.  
  331. //------------------------------------------------------
  332.