Notes
Slide Show
Outline
1
Alpha Five
2
A Short History
  • OLE  - Object Linking & Embedding
    • Primarily about Documents
    • Introduction of scripting of objects
  • Linking vs. Embedding
    • Linking – References to Files
    • Embedding – Files live with the program
  • Servers activate inside the client
  • COM – Component Object Model
3
ActiveX
  • Re-branding of OLE
  • Introduction of Windowing Controls
    • Graphs
    • Grids
    • Date Controls
  • Recognition of the importance of scripting
  • Far more third-party controls than previously
4
What is Automation?
  • Using an object written by someone else as if it were part of my own application
    • Reading properties


      • dim Title as C
      • Title = someobject.Title


    • Writing Properties


      • someobject.Title = “Hello World!”

5
What is Automation? (continued)
  • Calling functions


      • someObject.Recalculate()
  • Responding to events
    • Objects “trigger” events by calling functions
    • You implement those functions only if you care
    • Example


      • function Click as V (x as B, y as N)
      •   msg = “User clicked at x = “ + x + “ and y = “ + y
      •   ui_msg_box(Just Testing, msg)
      • end function
6
Finding ActiveX Objects
  • Objects are registered at install time
    • Listed in the Windows Registry
    • Entries describe
      • Properties, Events & Methods (functions)
      • How to create/load and use the object
      • Identifies how the object should be used
        • Control
        • Programmable
        • Insertable

7
Using a Programmable Object
  • Creating a new object requires a short name
    • Programmatic Identifier (ProgId)
  • Call ole.create() to create a new instance
  • Access the object using dot (”.”) syntax
  • Example


      • dim someobject as p
      • someobject  = ole.create(“owc.spreadsheet”)
      • someobject.Range("A1").Select()
      • someobject.ActiveCell = "Name"



8
Using Controls with Forms
  • Select ActiveX (the big X) from the ToolBox and place a rectangle on the workspace.


9
Using Controls with Forms (continued)
  • A dialog will open listing available controls.
  • Select your control from the list and click Insert.


10
Using Controls with Forms (continued)
  • Access control properties, and methods in form scripts with the syntax:
        • dim object as p
        • object = my_control_name.activex.this
        • if object.title = “” then
        • object.Title = “Hello World!”
        • object.Refresh()
        • end if

11
Using Controls with Forms (continued)
  • Select ActiveX Event from the menu or right-mouse button to script events published by the control.


12
Using Controls with Forms (continued)
13
Using Controls with XDialogs
  • Declare variables to identify the control


      • dim img as p
      • dim img.object as p
      • dim img.class  as c
      • img.class = "imaging.editctrl.1"


14
Using Controls with XDialogs (continued)
  • Add the control to the dialog definition


  • {activex=80,25img}
15
Using Controls with XDialogs (continued)
  • Access control properties, and methods in dialog event handlers with the syntax:
        • dim object as p
        • object = img.object
        • if object.title = “” then
        • object.Title = “Hello World!”
        • object.Refresh()
        • end if

16
Using Controls with XDialogs (continued)
  • Script event handlers for the control


      • img.events = <<%code%


      • function Click as v ()
      • self.zoom = iif(self.Zoom + 10 < 6554, self.zoom + 10, 2)
      • self.Display()
      • end function


      • function DblClick as v ()
      • ‘ To Do
      • end function


      • %code%

17
Using Controls with XDialogs (continued)
18
Browsing ActiveX Registry Entries