home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l391 / 4.ddi / CUSTREG.AS$ / CUSTREG.bin
Encoding:
Text File  |  1992-08-19  |  10.2 KB  |  230 lines

  1. ; ----------------------------------------------------------------------------
  2. ; CUSTREG.ASM: 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 <RegisterFile>          ; Assumes Masm 6.0 compiler
  17. ;    BC /o <TemplateFile>;         ; Use appropriate compiler for template source code
  18. ;    DEL <TemplateFile.LIB>        ; Delete existing library if exists
  19. ;    LIB <TemplateFile.LIB>+<RegisterFile.OBJ>+<TemplateFile.OBJ>
  20. ;    LINK /Q <TemplateFile.LIB>,<TemplateFile.QLB>,,VBDOSQLB.LIB;
  21. ; You can combine multiple custom controls into one Quick library for
  22. ; use within the programming environment as follows:
  23. ;    DEL <CombinedLib.LIB>         ; Delete existing library if exists
  24. ;    LIB <CombinedLib.LIB>+<Cust1.LIB>+<Cust2.LIB>+<CustN.LIB>
  25. ;    LINK /Q <CombinedLib.LIB>,<CombinedLib.QLB>,,VBDOSQLB.LIB;
  26. ; To create an Alternate Math custom control library (instead of an
  27. ; Emulator Math custom control library as shown above), compile the 
  28. ; TemplateFile with the /FPa switch.  Note, an Altmath library cannot be
  29. ; used to create a Quick Library.
  30. ;
  31. ;
  32. ; Copyright (C) 1982-1992 Microsoft Corporation
  33. ;
  34. ; You have a royalty-free right to use, modify, reproduce
  35. ; and distribute the sample applications and toolkits provided with
  36. ; Visual Basic for MS-DOS (and/or any modified version)
  37. ; in any way you find useful, provided that you agree that
  38. ; Microsoft has no warranty, obligations or liability for
  39. ; any of the sample applications or toolkits.
  40. ; ----------------------------------------------------------------------------
  41.  
  42.  
  43. ; Memory model and include files.
  44.  
  45. .MODEL    medium, basic
  46. INCLUDE   CUSTINCL.INC
  47. ; Far externs for the custom control event handlers.
  48.  
  49. EXTRN   MyControl_CClick:FAR
  50. EXTRN   MyControl_CKeyPress:FAR
  51. EXTRN   MyControl_CIntegerGet:FAR
  52.  
  53.  
  54.    PUBLIC BCC$MYCONTROL                      ; Public declaration to pull in necessary
  55.    BCC$MYCONTROL  EQU 5253H                  ; code when linking EXE file.  Must consist of
  56.                            ; 'BCC$' plus TypeID string or custom control
  57.                            ; code will not be linked into program.
  58.  
  59.  
  60. ; Custom control initializer segment
  61. ;
  62. ; Note, more than one custom control's initialization
  63. ; information can be contained in this segment.  Simply
  64. ; provide the required information in correct order for
  65. ; each custom control.
  66.  
  67. DGROUP GROUP XECIB, XECI, XECIE
  68.  
  69. XECIB  SEGMENT WORD PUBLIC 'DATA'  ; Start of the initializer segment
  70. XECIB  ENDS
  71.  
  72. XECI   SEGMENT WORD PUBLIC 'DATA'
  73.    DW OFFSET MyControlType         ; Custom control TypeID string.
  74.                            ; Must be alphanumeric beginning
  75.                            ; with alphabetic character.
  76.                            ; Near pointer to 0 terminated
  77.                            ; string in data segment
  78.    DW lenMyControlType             ; Length of string (excluding
  79.                            ; terminating zero, max = 25)
  80.    DD MyControlIsHandler           ; Far pointer to IsHandler
  81.    DW 0                    ; Flags (0,1) determines if control
  82.                            ; can be a container object.
  83.  
  84.    BeginEventMasks         ; Event masks
  85.       MaskItem EVENT_Change
  86.       MaskItem EVENT_DropDown
  87.       MaskItem EVENT_Load
  88.       MaskItem EVENT_Paint
  89.       MaskItem EVENT_PathChange
  90.       MaskItem EVENT_PatternChange
  91.       MaskItem EVENT_Resize
  92.       MaskItem EVENT_Timer
  93.       MaskItem EVENT_Unload
  94.    EndEventMasks
  95.    BeginPropertyMasks      ; Property masks
  96.       MaskItem PROP_Archive
  97.       MaskItem PROP_AutoRedraw
  98.       MaskItem PROP_Checked
  99.       MaskItem PROP_Column
  100.       MaskItem PROP_Drive
  101.       MaskItem PROP_Filename
  102.       MaskItem PROP_Hidden
  103.       MaskItem PROP_Interval
  104.       MaskItem PROP_LargeChange
  105.       MaskItem PROP_ListCount
  106.       MaskItem PROP_ListIndex
  107.       MaskItem PROP_Max
  108.       MaskItem PROP_Min
  109.       MaskItem PROP_MultiLine
  110.       MaskItem PROP_Normal
  111.       MaskItem PROP_Path
  112.       MaskItem PROP_Pattern
  113.       MaskItem PROP_ReadOnly
  114.       MaskItem PROP_Row
  115.       MaskItem PROP_ScrollBars
  116.       MaskItem PROP_SelLength
  117.       MaskItem PROP_SelStart
  118.       MaskItem PROP_SelText
  119.       MaskItem PROP_SmallChange
  120.       MaskItem PROP_Sorted
  121.       MaskItem PROP_System
  122.       MaskItem PROP_Text
  123.    EndPropertyMasks
  124. XECI   ENDS
  125.  
  126. XECIE  SEGMENT WORD PUBLIC 'DATA'  ; End of the initializer segment.
  127. XECIE  ENDS
  128.  
  129.  
  130. .DATA
  131.  
  132.    MyControlType DB    "MyControl",0h        ; Custom control TypeID string.
  133.                            ; Must be alphanumeric beginning
  134.                            ; with alphabetic character.
  135.    lenMyControlType = $ - MyControlType - 1  ; Length of string (excluding
  136.                            ; terminating zero, max = 25)
  137.  
  138.  
  139. .CODE   MyControl_TEXT
  140.  
  141.    ; Custom control event handler address table.
  142.    ; For use with a table driven IsHandler routine.  Table contains
  143.    ; address of event handler routine for events that will be
  144.    ; handled/intercepted by the custom control.  Table contains a
  145.    ; Long 0 for events that will not be handled/intercepted by the
  146.    ; custom control but passed directly to the user's code where
  147.    ; applicable.
  148.  
  149.    MyControlTable LABEL DWORD
  150.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  151.         DD    MyControl_CClick                              ;Click
  152.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  153.         DD    0                                             ;DblClick
  154.         DD    0                                             ;DragDrop
  155.         DD    0                                             ;DragOver
  156.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  157.         DD    0                                             ;GotFocus
  158.         DD    0                                             ;KeyDown
  159.         DD    MyControl_CKeyPress                           ;KeyPress
  160.         DD    0                                             ;KeyUp
  161.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  162.         DD    0                                             ;LostFocus
  163.         DD    0                                             ;MouseDown
  164.         DD    0                                             ;MouseMove
  165.         DD    0                                             ;MouseUp
  166.         DD    0                                             ;Paint
  167.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  168.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  169.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  170.         DD    0                                             ;Timer
  171.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  172.         DD    0                                             ;Load
  173.         DD    MyControl_CIntegerGet                         ;IntegerGet
  174.         DD    0                                             ;IntegerSet
  175.         DD    0                                             ;LongGet
  176.         DD    0                                             ;LongSet
  177.         DD    0                                             ;StringGet
  178.         DD    0                                             ;StringSet
  179.         DD    0                                             ;Unload
  180.         DD    0                                             ;MthAddItem
  181.         DD    0                                             ;MthCls
  182.         DD    0                                             ;MthHide
  183.         DD    0                                             ;MthMove
  184.         DD    0                                             ;MthPrint
  185.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  186.         DD    0                                             ;MthRefresh
  187.         DD    0                                             ;MthRemoveItem
  188.         DD    0                                             ;MthSetFocus
  189.         DD    0                                             ;MthShow
  190.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  191.         DD    0                                             ; Skipped table entry: DO NOT REMOVE
  192.         DD    0                                             ;MthDrag
  193.  
  194.     lenMyControlTable = ($ - MyControlTable)/4    ; Number of entries in table
  195.  
  196.  
  197.    ; IsHandler routine for the custom control.  This routine is 
  198.    ; called by Visual Basic each time an event occurs for the custom control.
  199.    ; The EventID for the event is passed to the IsHandler routine
  200.    ; which returns the address of the custom control's event handler
  201.    ; routine for that event.  If the custom control does not want to
  202.    ; handle/intercept the event, IsHandler returns a Long 0 and the event
  203.    ; is passed to the user's code if applicable.
  204.    ; 
  205.    ; This IsHandler routine uses a table driven approach for returning
  206.    ; event handler address or 0 (table is defined above).
  207.    ; Different methods can be used to return this information however.
  208.  
  209.     PUBLIC   MyControlIsHandler
  210.    MyControlIsHandler PROC , EventId:WORD
  211.  
  212.       MOV    bx, EventId                ;[bx] = event Id
  213.       CMP    bx, lenMyControlTable   ; Is value in range?
  214.       JAE    OutOfRange                ;Break and return 0:0
  215.       ADD    bx, bx
  216.       ADD    bx, bx                    ;[bx] = dword index
  217.       LES    ax, MyControlTable[bx-4]   ;[es:ax] = address of handler
  218.       MOV    dx, es                    ;[dx:ax] = address of handler / 0
  219.       RET
  220.  
  221. OutOfRange:
  222.       XOR    ax, ax
  223.       CWD
  224.       RET
  225.  
  226.    MyControlIsHandler ENDP
  227.  
  228. END
  229.  
  230.