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

  1. ; ----------------------------------------------------------------------------
  2. ; CUSTCALL.ASM: Custom Control Callback Examples
  3. ;
  4. ; Copyright (C) 1982-1992 Microsoft Corporation
  5. ;
  6. ; You have a royalty-free right to use, modify, reproduce
  7. ; and distribute the sample applications and toolkits provided with
  8. ; Visual Basic for MS-DOS (and/or any modified version)
  9. ; in any way you find useful, provided that you agree that
  10. ; Microsoft has no warranty, obligations or liability for
  11. ; any of the sample applications or toolkits.
  12. ;
  13. ; NOTE: This file demonstrates sample usage of the custom control
  14. ; callbacks. It is provided for examples of how different
  15. ; callbacks work. It is not part of a working custom control.
  16. ; ----------------------------------------------------------------------------
  17.  
  18. ; Include file containing constant definitions for
  19. ; Property, Event, Method and ControlType ID numbers.
  20. include custincl.inc
  21.  
  22. ; Declarations for custom control callbacks.
  23. ; These callbacks are used to set and get custom control
  24. ; properties and invoke custom control methods and events.
  25. ;
  26.  
  27. ; Declare callbacks for setting and getting property values
  28. extrn SetProperty:far
  29. extrn GetProperty:far
  30.  
  31. ; Declare callback for getting a control's container object.
  32. ; This callback returns a control ID for the container object.
  33. extrn GetContainer:far
  34.  
  35. ; Declare callback for setting a control's attributes.
  36. extrn SetAttribute:far            ; Refer to custom control section
  37.                                   ; in README.TXt for information on
  38.                                   ; using this callback.
  39.  
  40. ; Declare callbacks for invoking methods and events.  These
  41. ; callbacks accept a variable number and types of arguments
  42. ; depending on the method or event that is being invoked.
  43. extrn InvokeEvent:far
  44. extrn InvokeMethod:far
  45.  
  46. _DATA   SEGMENT WORD PUBLIC 'DATA'
  47.  
  48. ControlID1  DW  0       ; Storage for ControlId value
  49. ControlID2  DW  0       ; Storage for ControlId value
  50. SourceControlID DW  0   ; ControlId value for DragDrop source
  51.  
  52. Left1       DW  0       ; stores custom1.left
  53. Top1        DW  0       ; stores Top
  54. Interval1   DD  0       ; stores custom1.interval
  55. SDVal1      DD  0       ; stores custom1.caption
  56. ContainerID DW  0       ; stores parent ID
  57. CoordX      DD  0       ; stores x coord
  58. CoordY      DD  0       ; store y coord
  59. TypeOfControl   DW  0   ; stores TYPEOF info
  60.  
  61. _DATA   ENDS
  62.  
  63. DGROUP  GROUP _DATA
  64.  
  65. MYCONTROL_CODE SEGMENT BYTE PUBLIC 'CODE'
  66.     ASSUME  CS:MYCONTROL_CODE
  67.     ASSUME  DS:DGROUP
  68.  
  69.  
  70. ; -------------------------------------------------------------------
  71. ; The examples below assume that SDVal1 contains a valid Basic
  72. ; string descriptor.  See the Mixed-Language Programming chapter
  73. ; in the Professional Features Guide for more information.
  74. ; ---------------------------------------------------------------------
  75.  
  76.  
  77. ; SetAttribute example
  78.  
  79. ; Example of using the SetAttribute callback to specify access
  80. ; key for a custom control.  Note, it is up to the custom control
  81. ; developer to actually display the text containing the access key.
  82.  
  83.     ; Set Alt+A or Alt+a as the access key.
  84.     mov     ax,ControlID1
  85.     push    ax
  86.     mov     ax,ATTR_AccessKey
  87.     push    ax
  88.     mov     ax,65           ; Alt+A.
  89.     push    ax
  90.     call    SetAttribute
  91.     
  92.  
  93. ; Property set examples
  94.  
  95. ; SetProperty is a callback used to set INTEGER, LONG, and STRING properties.
  96. ; All arguments to this routine must be passed BYVAL (the string for
  97. ; string property set must be passed by reference however).  The callback
  98. ; determines property type (INTEGER, LONG, STRING) based on the
  99. ; PropertyID (last argument).  If an incorrect value type is passed
  100. ; for the given PropertyID, unpredictable results will occur.
  101.  
  102. ; control.left = 25
  103.     mov     ax,25
  104.     push    ax
  105.     mov     ax,ControlID1
  106.     push    ax
  107.     mov     ax,PROP_Left
  108.     push    ax
  109.     call    SetProperty
  110.  
  111. ; control.interval = 50000
  112.     mov     ax,0H
  113.     push    ax
  114.     mov     ax,0C350H
  115.     push    ax
  116.     mov     ax,ControlID1
  117.     push    ax
  118.     mov     ax,PROP_Interval
  119.     push    ax
  120.     call    SetProperty
  121.  
  122. ; control.caption = SDVal
  123.     mov     ax,offset SDVal1
  124.     push    ax
  125.     mov     ax,ControlID1
  126.     push    ax
  127.     mov     ax,PROP_Caption
  128.     push    ax
  129.     call    SetProperty
  130.  
  131.  
  132. ; Property get examples
  133.  
  134. ; GetProperty is a callback used to get INTEGER, LONG, and STRING properties.
  135. ; The first argument to this routine must be passed by reference,
  136. ; all others must be passed BYVAL.  The property value corresponding
  137. ; to the PropertyID (last argument) is returned via the first argument (not
  138. ; returned by Getproperty itself).  The callback determines
  139. ; property type (INTEGER, LONG, STRING) based on the PropertyID
  140. ; (last argument).  If an incorrect data type is passed
  141. ; for the given PropertyID, unpredictable results will occur.
  142.  
  143. ; Left1 = Control1.left
  144.     mov     ax,offset Left1
  145.     push    ax
  146.     mov     ax,ControlID1
  147.     push    ax
  148.     mov     ax,PROP_Left
  149.     push    ax
  150.     call    GetProperty
  151.  
  152. ; Interval1 = Control1.Interval
  153.     mov     ax,offset Interval1
  154.     push    ax
  155.     mov     ax,ControlID1
  156.     push    ax
  157.     mov     ax,PROP_Interval
  158.     push    ax
  159.     call    GetProperty
  160.  
  161. ; SDVal1 = Control1.caption
  162.     mov     ax,offset SDVal1
  163.     push    ax
  164.     mov     ax,ControlID1
  165.     push    ax
  166.     mov     ax,PROP_Caption
  167.     push    ax
  168.     call    GetProperty
  169.  
  170.  
  171. ; Example of using the GetProperty callback to retrieve the
  172. ; control's type (TYPEOF).
  173.     mov     ax,offset TypeOfControl
  174.     push    ax
  175.     mov     ax,ControlID1
  176.     push    ax
  177.     mov     ax,PROP_TypeOf
  178.     push    ax
  179.     call    GetProperty
  180.     cmp     TypeOfControl,TYPEOF_Form   ; found a FORM?
  181.     jne     @F                          ; branch if not.
  182.     ; Add code to print, "FORM found as container"
  183.  
  184.  
  185. @@:
  186.  
  187. ; GetContainer example
  188.  
  189. ; Example of using the GetContainer callback to retrieve
  190. ; a control's container object (returned as a ControlID).
  191.     mov     ax,ControlID1
  192.     push    ax
  193.     call    GetContainer
  194.     mov     ContainerID,ax
  195.  
  196.  
  197. ; InvokeEvent example
  198.  
  199. ; Example of using the InvokeEvent callback to trigger a
  200. ; custom control's DragDrop event and execute user's DragDrop
  201. ; code if it exists.  The standard event arguments (passed to
  202. ; the user's code) are listed
  203. ; first, followed by the ControlID and EventID for the control
  204. ; and event to be triggered.  If the arguments passed don't match
  205. ; the number and type of arguments expected for the EventID,
  206. ; unpredictable results will occur.
  207.  
  208.     mov     ax,SourceControlID
  209.     push    ax
  210.     mov     ax,offset DGROUP:CoordX
  211.     push    ax
  212.     mov     ax,offset DGROUP:CoordY
  213.     push    ax
  214.     mov     ax,ControlID1
  215.     push    ax
  216.     mov     ax,EVENT_DragDrop
  217.     push    ax
  218.     call    InvokeEvent
  219.  
  220.  
  221. ; InvokeMethod example
  222.  
  223. ; Example of using the InvokeMethod callback to invoke
  224. ; a custom control's MOVE method.  The MOVE method can take
  225. ; up to 4 arguments (left, top, width, height).  The
  226. ; order in which the arguments are passed to InvokeMethod
  227. ; is the same as that for the method, followed by the
  228. ; number of arguments and the ControlID and
  229. ; MethodID.  All arguments must be passed by value.
  230. ; If the arguments passed don't match the number and type of
  231. ; arguments expected for the MethodID, unpredictable results will occur.
  232.  
  233.     mov     ax,Left1
  234.     push    ax
  235.     mov     ax,Top1
  236.     push    ax
  237.     mov     ax,2
  238.     push    ax
  239.     mov     ax,ControlID1
  240.     push    ax
  241.     mov     ax,METHOD_Move
  242.     push    ax
  243.     call    InvokeMethod
  244.  
  245. MYCONTROL_CODE  ENDS
  246.  
  247. END
  248.  
  249.