home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / REFERENC / LEARNVBX / MULTI.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-25  |  9.6 KB  |  281 lines

  1. //---------------------------------------------------------------------------
  2. // MULTI.h
  3. //---------------------------------------------------------------------------
  4.  
  5. //---------------------------------------------------------------------------
  6. // Helpful Macros
  7. //---------------------------------------------------------------------------
  8. #define OFFSETIN( struc, field )  ( (USHORT)&( ((struc *)0)->field ) )
  9.  
  10.  
  11. //---------------------------------------------------------------------------
  12. // Resource ID's
  13. //---------------------------------------------------------------------------
  14. // Toolbox bitmap resource IDs.
  15. //---------------------------------------------------------------------------
  16. #define IDBMP_MULTI             8000
  17. #define IDBMP_MULTIDOWN          8001
  18. #define IDBMP_MULTIMONO          8003
  19. #define IDBMP_MULTIEGA           8006
  20.  
  21.  
  22. //---------------------------------------------------------------------------
  23. // MULTI control data and structs
  24. //---------------------------------------------------------------------------
  25. /* Count and Text are both holding areas shared by the custom
  26.    properties implemented within MultiListBox
  27. */
  28. typedef struct tagMULTI
  29. {
  30.     int hwnd;    /* all property data space should be declared here */
  31.             /* For MULTI, the only property that is custom is  */
  32.             /* the hwnd property (was not supplied as std in VB1) */
  33. } MULTI;
  34.  
  35. typedef MULTI FAR * PMULTI;
  36.  
  37. #define MULTIDEREF(hctl)     ((PMULTI)VBDerefControl(hctl))
  38.  
  39.  
  40. //---------------------------------------------------------------------------
  41. // Control Procedure
  42. //---------------------------------------------------------------------------
  43. LONG FAR PASCAL _export MultiCtlProc(HCTL, HWND, USHORT, USHORT, LONG);
  44.  
  45.  
  46. #ifndef RC_INVOKED
  47. /* IT IS IMPORTANT THAT the declarations of space (vs pointers) be invoked once
  48.    during the compile.  I set a CTL_DATA precompiler flag to indicate when just
  49.    before the INCLUDE "multi.h" in my control processing (multi.c)*/
  50. #ifdef CTL_DATA
  51. //---------------------------------------------------------------------------
  52. // Property list
  53. //---------------------------------------------------------------------------
  54. // Define the consecutive indicies for the properties
  55. // These values are indices into the property table
  56. /* for VB2/3 implementations, update the list to reflect the more recent
  57.    standard properties.  This list was standard for VB version 1
  58. */
  59. //---------------------------------------------------------------------------
  60. #define IPROP_MULTI_NAME           0x0000
  61. #define IPROP_MULTI_INDEX          0x0001
  62. #define IPROP_MULTI_PARENT         0x0002
  63. #define IPROP_MULTI_BACKCOLOR      0x0003
  64. #define IPROP_MULTI_LEFT           0x0004
  65. #define IPROP_MULTI_TOP            0x0005
  66. #define IPROP_MULTI_WIDTH          0x0006
  67. #define IPROP_MULTI_HEIGHT         0x0007
  68. #define IPROP_MULTI_ENABLED        0x0008
  69. #define IPROP_MULTI_VISIBLE        0x0009
  70. #define IPROP_MULTI_MOUSEPOINTER   0x000A
  71. #define IPROP_MULTI_FONTNAME       0x000B
  72. #define IPROP_MULTI_FONTSIZE       0x000C
  73. #define IPROP_MULTI_FONTBOLD       0x000D
  74. #define IPROP_MULTI_FONTITALIC     0x000E
  75. #define IPROP_MULTI_FONTSTRIKE     0x000F
  76. #define IPROP_MULTI_FONTUNDER      0x0010
  77. #define IPROP_MULTI_DRAG           0x0011
  78. #define IPROP_MULTI_DRAGICON       0x0012
  79. #define IPROP_MULTI_TABINDEX       0x0013
  80. #define IPROP_MULTI_TABSTOP        0x0014
  81. #define IPROP_MULTI_TAG            0x0015
  82.  
  83. /* custom properties begin below    */
  84. /* for each custom property, must   */
  85. /* define a property info structure */
  86. #define IPROP_MULTI_SELCOUNT       0x0016  /* get returns select count */
  87. #define IPROP_MULTI_LISTCOUNT      0x0017  /* get returns list count */
  88. #define IPROP_MULTI_FIREBACK       0x0018  /* change fires select dump */
  89. #define IPROP_MULTI_LIST           0x0019  /* array property : whole list */
  90. #define IPROP_MULTI_SELLIST        0x001A  /* array property : selections */
  91. #define IPROP_MULTI_LISTDATA       0x001B  /* array of list data items    */
  92. #define IPROP_MULTI_HWND           0x001C  /* hwnd of window              */
  93. #define IPROP_MULTI_CARET          0x001D  /* caret location              */
  94.  
  95. /* PROPINFO structures provide VB with information on the property name,
  96.    data type, get-able, setable, and show in property window information.
  97. PROPINFO P_Selcount = 
  98. {
  99.     "SelCount",
  100.     DT_SHORT | PF_fGetMsg | PF_fSetMsg | PF_fNoShow,
  101.     0
  102. };
  103.  
  104. PROPINFO P_Listcount = 
  105. {
  106.     "ListCount",
  107.     DT_SHORT | PF_fGetMsg | PF_fSetMsg | PF_fNoShow,
  108.     0
  109. };
  110.  
  111. PROPINFO P_Caret = 
  112. {
  113.     "Caret",
  114.     DT_SHORT | PF_fGetMsg | PF_fSetMsg | PF_fNoShow,
  115.     0
  116. };
  117.  
  118. PROPINFO P_Hwnd = 
  119. {
  120.     "Hwnd",
  121.     DT_SHORT | PF_fGetMsg |  PF_fNoShow | PF_fNoRuntimeW,
  122.     0
  123. };
  124. /* setting fillback at run-time will cause the custom event to fire in sequence */
  125. PROPINFO P_Fillback = 
  126. {
  127.     "FillBack",
  128.     DT_SHORT | PF_fSetMsg | PF_fNoShow,
  129.     0
  130. };
  131. /* the PF_fPropArray flag tells VB if its an array type property */
  132. PROPINFO P_List = 
  133. {
  134.     "List",
  135.     DT_HSZ | PF_fSetMsg | PF_fPropArray | PF_fGetMsg | PF_fNoShow,
  136.     0
  137. };
  138.  
  139. PROPINFO P_SelList = 
  140. {
  141.     "SelList",
  142.     DT_HSZ | PF_fGetMsg | PF_fSetMsg | PF_fPropArray |  PF_fNoShow,
  143.     0
  144. };
  145.  
  146. PROPINFO P_Listdata = 
  147. {
  148.     "ListData",
  149.     DT_LONG | PF_fSetMsg | PF_fPropArray | PF_fGetMsg | PF_fNoShow,
  150.     0
  151. };
  152. /* finally, the property table for the control.  The names below MUST
  153.    appear in the same order (index value wise) as the IPROP defines above */
  154. PPROPINFO proplistMulti[] =
  155. {
  156.     PPROPINFO_STD_CTLNAME,
  157.     PPROPINFO_STD_INDEX,
  158.     PPROPINFO_STD_PARENT,
  159.     PPROPINFO_STD_BACKCOLOR,
  160.     PPROPINFO_STD_LEFT,
  161.     PPROPINFO_STD_TOP,
  162.     PPROPINFO_STD_WIDTH,
  163.     PPROPINFO_STD_HEIGHT,
  164.     PPROPINFO_STD_ENABLED,
  165.     PPROPINFO_STD_VISIBLE,
  166.     PPROPINFO_STD_MOUSEPOINTER,
  167.     PPROPINFO_STD_FONTNAME,
  168.     PPROPINFO_STD_FONTSIZE,
  169.     PPROPINFO_STD_FONTBOLD,
  170.     PPROPINFO_STD_FONTITALIC,
  171.     PPROPINFO_STD_FONTSTRIKE,
  172.     PPROPINFO_STD_FONTUNDER,
  173.     PPROPINFO_STD_DRAGMODE,
  174.     PPROPINFO_STD_DRAGICON,
  175.     PPROPINFO_STD_TABINDEX,
  176.     PPROPINFO_STD_TABSTOP,
  177.     PPROPINFO_STD_TAG,
  178.     &P_Selcount,
  179.     &P_Listcount,
  180.     &P_Fillback,
  181.     &P_List,
  182.     &P_SelList,
  183.     &P_Listdata,
  184.     &P_Hwnd,
  185.     &P_Caret,
  186.     NULL
  187. };
  188. #endif  // CTL_DATA
  189.  
  190.  
  191.  
  192. //---------------------------------------------------------------------------
  193. // Event procedure parameter prototypes
  194. //---------------------------------------------------------------------------
  195. /* more stuff for inclusion only once */
  196. #ifdef CTL_DATA
  197. /* descriptive word arrays which tell VB the data types to be passed */
  198. /* to the event procedures.  Remember, pointers are passed in the    */
  199. /* actual code (see multi.c params[3,4].)                            */
  200. WORD Parms_3[] = {ET_SD, ET_I2, ET_I4}; 
  201.  
  202. /*WORD Parms_4[] = {ET_SD, ET_I2, ET_I2, ET_I4}; */
  203.  
  204. /* click is standard : commented out, still here for example sake */
  205. /*EVENTINFO Event_Click =
  206. {
  207.     "Click",
  208.     4,
  209.     8,
  210.     Parms_4,
  211.     "Selection as string, Offset as integer,  Selected as integer, DataVal as long"
  212. }; */
  213. /* my custom event, SelectDump, will be called with three parameters (a string, a short, a long)
  214.    as I've defined my PARMS_3 array (ET_SD is string data, I2 = 2 byte int, I4 is 4 byte int)
  215.    The EVENTINFO structure is the prototype that defines the name of the event (e.g. XX_Selectdump)
  216.    the number of args (the third value is ALWAYS double the second arg and REQUIRED),
  217.    as well as the text for the automatic declaration list for the subroutine 
  218. */
  219. EVENTINFO Event_SelectDump =
  220. {
  221.     "SelectDump",
  222.     3,
  223.     6,
  224.     Parms_3,
  225.     "Selection as string, Offset as integer, DataVal as long"
  226. };
  227. #endif  // CTL_DATA
  228. //---------------------------------------------------------------------------
  229. // Event list
  230. //---------------------------------------------------------------------------
  231. // Define the consecutive indicies for the events
  232. // These defines are indices into the eventlistMulti table below
  233. // Event tables are kept in ALPHABETIC ORDER (MUST)
  234. //---------------------------------------------------------------------------
  235. #define EVENT_MULTI_SELECTDUMP   9
  236.  
  237. #ifdef CTL_DATA
  238. PEVENTINFO eventlistMulti[] =
  239. {
  240.     PEVENTINFO_STD_CLICK,
  241.     PEVENTINFO_STD_DBLCLICK,
  242.     PEVENTINFO_STD_DRAGDROP,
  243.     PEVENTINFO_STD_DRAGOVER,
  244.     PEVENTINFO_STD_GOTFOCUS,
  245.     PEVENTINFO_STD_KEYDOWN,
  246.     PEVENTINFO_STD_KEYPRESS,
  247.     PEVENTINFO_STD_KEYUP,
  248.     PEVENTINFO_STD_LOSTFOCUS,
  249.     &Event_SelectDump,
  250.     NULL
  251. };
  252. #endif  // CTL_DATA
  253.  
  254.  
  255. //---------------------------------------------------------------------------
  256. // Model struct
  257. //---------------------------------------------------------------------------
  258. // Define the control model (using the event and property structures).
  259. //---------------------------------------------------------------------------
  260. #ifdef CTL_DATA
  261. MODEL modelPush =
  262. {
  263.     VB_VERSION,                         // VB version being used
  264.     MODEL_fFocusOk | MODEL_fArrows,     // MODEL flags
  265.     (PCTLPROC)MultiCtlProc,              // Control procedure
  266.     CS_VREDRAW | CS_HREDRAW,            // Class style
  267.     WS_CHILD | LBS_EXTENDEDSEL | LBS_STANDARD,       // Default Window style
  268.     sizeof(MULTI),                       // cbCtlExtra for MULTI structure
  269.     IDBMP_MULTI,                         // Palette bitmap ID
  270.     "Multi",                             // Default control name
  271.     "MultiList",                         // Visual Basic class name
  272.     "Listbox",                           // Parent class name
  273.     proplistMulti,                       // Properties list
  274.     eventlistMulti                       // Events list
  275. };
  276. #endif  // CTL_DATA
  277.  
  278. #endif  // RC_INVOKED
  279.  
  280. //---------------------------------------------------------------------------
  281.