home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l391_1 / 2.ddi / SPINREG.AS$ / SPINREG.bin
Encoding:
Text File  |  1992-08-19  |  11.0 KB  |  266 lines

  1. ; ----------------------------------------------------------------------------
  2. ; SPINREG.ASM: Spin Custom Control Initialization and
  3. ; and IsHandler routines.
  4. ;
  5. ; Initializer segment and IsHandler routine created by
  6. ; CUSTGEN.EXE (Custom Control Template Generator).
  7. ;
  8. ; CUSTGEN.EXE is a utility provided to make custom
  9. ; control development easier.  It allows you to select
  10. ; the events you want your custom control to respond to,
  11. ; then generates code templates and a custom control
  12. ; registration routine for these events.
  13. ;
  14. ; Modify the code template file as necessary, then build
  15. ; your custom control as follows:
  16. ;    ML -c spinreg.asm          ; Assumes Masm 6.0 compiler
  17. ;    BC /x/o/d spin.bas;        ; Use appropriate compiler for template source code
  18. ;    DEL spin.lib               ; Delete existing library if exists
  19. ;    LIB spin.lib+spinreg.obj+spin.obj
  20. ;    LINK /Q spin.lib,spin.qlb,,VBDOSQLB.LIB;
  21. ; You can combine the spin custom control with other custom controls
  22. ; into one Quick library for use within the programming environment 
  23. ; as follows:
  24. ;    DEL <CombinedLib.LIB>         ; Delete existing library if exists
  25. ;    LIB <CombinedLib.LIB>+spin.lib+<Cust2.LIB>+<CustN.LIB>
  26. ;    LINK /Q <CombinedLib.LIB>,<CombinedLib.QLB>,,VBDOSQLB.LIB;
  27. ; To create an Alternate Math custom control library (instead of an
  28. ; Emulator Math custom control library as shown above), compile the 
  29. ; TemplateFile with the /FPa switch.  Note, an Altmath library cannot be
  30. ; used to create a Quick Library.
  31. ;
  32. ;
  33. ; Copyright (C) 1982-1992 Microsoft Corporation
  34. ;
  35. ; You have a royalty-free right to use, modify, reproduce
  36. ; and distribute the sample applications and toolkits provided with
  37. ; Visual Basic for MS-DOS (and/or any modified version)
  38. ; in any way you find useful, provided that you agree that
  39. ; Microsoft has no warranty, obligations or liability for
  40. ; any of the sample applications or toolkits.
  41. ; ----------------------------------------------------------------------------
  42.  
  43.  
  44. ; Memory model and include files.
  45.  
  46. .MODEL    medium, basic
  47. INCLUDE   CUSTINCL.INC
  48.  
  49. ; Far externs for the custom control event handlers.
  50. EXTRN   Spin_CClick:FAR
  51. EXTRN   Spin_CDblClick:FAR
  52. EXTRN   Spin_CGotFocus:FAR
  53. EXTRN   Spin_CKeyDown:FAR
  54. EXTRN   Spin_CKeyPress:FAR
  55. EXTRN   Spin_CKeyUp:FAR
  56. EXTRN   Spin_CLostFocus:FAR
  57. EXTRN   Spin_CMouseDown:FAR
  58. EXTRN   Spin_CMouseMove:FAR
  59. EXTRN   Spin_CMouseUp:FAR
  60. EXTRN   Spin_CPaint:FAR
  61. EXTRN   Spin_CTimer:FAR
  62. EXTRN   Spin_CLoad:FAR
  63. EXTRN   Spin_CIntegerGet:FAR
  64. EXTRN   Spin_CIntegerSet:FAR
  65. EXTRN   Spin_CStringGet:FAR
  66. EXTRN   Spin_CStringSet:FAR
  67. EXTRN   Spin_CMthAddItem:FAR
  68. EXTRN   Spin_CMthCls:FAR
  69. EXTRN   Spin_CMthHide:FAR
  70. EXTRN   Spin_CMthMove:FAR
  71. EXTRN   Spin_CMthPrint:FAR
  72. EXTRN   Spin_CMthRemoveItem:FAR
  73. EXTRN   Spin_CMthShow:FAR
  74.  
  75.  
  76.    PUBLIC BCC$SPIN                      ; Public declaration to pull in necessary
  77.    BCC$SPIN  EQU 5253H                  ; code when linking EXE file.  Must consist of
  78.                            ; 'BCC$' plus TypeID string or custom control
  79.                            ; code will not be linked into program.
  80.  
  81.  
  82. ; Custom control initializer segment
  83. ;
  84. ; Note, more than one custom control's initialization
  85. ; information can be contained in this segment.  Simply
  86. ; provide the required information in correct order for
  87. ; each custom control.
  88.  
  89. DGROUP GROUP XECIB, XECI, XECIE
  90.  
  91. XECIB  SEGMENT WORD PUBLIC 'DATA'  ; Start of the initializer segment
  92. XECIB  ENDS
  93.  
  94. XECI   SEGMENT WORD PUBLIC 'DATA'
  95.    DW OFFSET SpinType         ; Custom control TypeID string.
  96.                            ; Must be alphanumeric beginning
  97.                            ; with alphabetic character.
  98.                            ; Near pointer to 0 terminated
  99.                            ; string in data segment
  100.    DW lenSpinType             ; Length of string (excluding
  101.                            ; terminating zero, max = 25)
  102.    DD SpinIsHandler           ; Far pointer to IsHandler
  103.    DW 0                    ; Flags (0,1) determines if control
  104.                            ; can be a container object.
  105.  
  106.    BeginEventMasks         ; Event masks
  107.       MaskItem EVENT_Change
  108.       MaskItem EVENT_Click
  109.       MaskItem EVENT_DblClick
  110.       MaskItem EVENT_DropDown
  111.       MaskItem EVENT_KeyDown
  112.       MaskItem EVENT_KeyPress
  113.       MaskItem EVENT_KeyUp
  114.       MaskItem EVENT_Load
  115.       MaskItem EVENT_MouseDown
  116.       MaskItem EVENT_MouseMove
  117.       MaskItem EVENT_MouseUp
  118.       MaskItem EVENT_Paint
  119.       MaskItem EVENT_PathChange
  120.       MaskItem EVENT_PatternChange
  121.       MaskItem EVENT_Resize
  122.       MaskItem EVENT_Timer
  123.       MaskItem EVENT_Unload
  124.    EndEventMasks
  125.    BeginPropertyMasks      ; Property masks
  126.       MaskItem PROP_Action
  127.       MaskItem PROP_Alignment
  128.       MaskItem PROP_Archive
  129.       MaskItem PROP_AutoRedraw
  130.       MaskItem PROP_BorderStyle
  131.       MaskItem PROP_Caption
  132.       MaskItem PROP_Checked
  133.       MaskItem PROP_Column
  134.       MaskItem PROP_Drive
  135.       MaskItem PROP_Filename
  136.       MaskItem PROP_Height
  137.       MaskItem PROP_Hidden
  138.       MaskItem PROP_LargeChange
  139.       MaskItem PROP_ListCount
  140.       MaskItem PROP_ListIndex
  141.       MaskItem PROP_Mode
  142.       MaskItem PROP_MultiLine
  143.       MaskItem PROP_Normal
  144.       MaskItem PROP_Path
  145.       MaskItem PROP_Pattern
  146.       MaskItem PROP_ReadOnly
  147.       MaskItem PROP_Row
  148.       MaskItem PROP_ScrollBars
  149.       MaskItem PROP_SelLength
  150.       MaskItem PROP_SelStart
  151.       MaskItem PROP_SelText
  152.       MaskItem PROP_SmallChange
  153.       MaskItem PROP_Sorted
  154.       MaskItem PROP_System
  155.       MaskItem PROP_Text
  156.       MaskItem PROP_Width
  157.    EndPropertyMasks
  158. XECI   ENDS
  159.  
  160. XECIE  SEGMENT WORD PUBLIC 'DATA'  ; End of the initializer segment.
  161. XECIE  ENDS
  162.  
  163.  
  164. .DATA
  165.  
  166.    SpinType DB    "Spin",0h        ; Custom control TypeID string.
  167.                            ; Must be alphanumeric beginning
  168.                            ; with alphabetic character.
  169.    lenSpinType = $ - SpinType - 1  ; Length of string (excluding
  170.                            ; terminating zero, max = 25)
  171.  
  172.  
  173. .CODE   Spin_TEXT
  174.  
  175.    ; Custom control event handler address table.
  176.    ; For use with a table driven IsHandler routine.  Table contains
  177.    ; address of event handler routine for events that will be
  178.    ; handled/intercepted by the custom control.  Table contains a
  179.    ; Long 0 for events that will not be handled/intercepted by the
  180.    ; custom control but passed directly to the user's code where
  181.    ; applicable.
  182.  
  183.    SpinTable LABEL DWORD
  184.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  185.         DD    Spin_CClick                                   ;Click
  186.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  187.         DD    Spin_CDblClick                                ;DblClick
  188.         DD    0                                             ;DragDrop
  189.         DD    0                                             ;DragOver
  190.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  191.         DD    Spin_CGotFocus                                ;GotFocus
  192.         DD    Spin_CKeyDown                                 ;KeyDown
  193.         DD    Spin_CKeyPress                                ;KeyPress
  194.         DD    Spin_CKeyUp                                   ;KeyUp
  195.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  196.         DD    Spin_CLostFocus                               ;LostFocus
  197.         DD    Spin_CMouseDown                               ;MouseDown
  198.         DD    Spin_CMouseMove                               ;MouseMove
  199.         DD    Spin_CMouseUp                                 ;MouseUp
  200.         DD    Spin_CPaint                                   ;Paint
  201.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  202.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  203.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  204.         DD    Spin_CTimer                                   ;Timer
  205.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  206.         DD    Spin_CLoad                                    ;Load
  207.         DD    Spin_CIntegerGet                              ;IntegerGet
  208.         DD    Spin_CIntegerSet                              ;IntegerSet
  209.         DD    0                                             ;LongGet
  210.         DD    0                                             ;LongSet
  211.         DD    Spin_CStringGet                               ;StringGet
  212.         DD    Spin_CStringSet                               ;StringSet
  213.         DD    0                                             ;Unload
  214.         DD    Spin_CMthAddItem                              ;MthAddItem
  215.         DD    Spin_CMthCls                                  ;MthCls
  216.         DD    Spin_CMthHide                                 ;MthHide
  217.         DD    Spin_CMthMove                                 ;MthMove
  218.         DD    Spin_CMthPrint                                ;MthPrint
  219.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  220.         DD    0                                             ;MthRefresh
  221.         DD    Spin_CMthRemoveItem                           ;MthRemoveItem
  222.         DD    0                                             ;MthSetFocus
  223.         DD    Spin_CMthShow                                 ;MthShow
  224.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  225.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  226.         DD    0                                             ;MthDrag
  227.  
  228.     lenSpinTable = ($ - SpinTable)/4    ; Number of entries in table
  229.  
  230.  
  231.    ; ((VOID _far *)NULL) SpinIsHandler (EventId)
  232.    ;
  233.    ; IsHandler routine for the custom control.  This routine is 
  234.    ; called by Visual Basic each time an event occurs for the custom control.
  235.    ; The EventID for the event is passed to the IsHandler routine
  236.    ; which returns the address of the custom control's event handler
  237.    ; routine for that event.  If the custom control does not want to
  238.    ; handle/intercept the event, IsHandler returns a Long 0 and the event
  239.    ; is passed to the user's code if applicable.
  240.    ; 
  241.    ; This IsHandler routine uses a table driven approach for returning
  242.    ; event handler address or 0 (table is defined above).
  243.    ; Different methods can be used to return this information however.
  244.  
  245.     PUBLIC   SpinIsHandler
  246.    SpinIsHandler PROC , EventId:WORD
  247.  
  248.       MOV    bx, EventId                ;[bx] = event Id
  249.       CMP    bx, lenSpinTable   ; Is value in range?
  250.       JAE    OutOfRange                ;Break and return 0:0
  251.       ADD    bx, bx
  252.       ADD    bx, bx                    ;[bx] = dword index
  253.       LES    ax, SpinTable[bx-4]   ;[es:ax] = address of handler
  254.       MOV    dx, es                    ;[dx:ax] = address of handler / 0
  255.       RET
  256.  
  257. OutOfRange:
  258.       XOR    ax, ax
  259.       CWD
  260.       RET
  261.  
  262.    SpinIsHandler ENDP
  263.  
  264. END
  265.  
  266.