findConnectionPoint {RDCOMEvents} | R Documentation |
To receive notification of events, on needs to first
locate the relevant event source or Connection Point.
A COM object can support multiple different event interfaces,
each of which corresponds to a different connection point.
This function queries the specified
COM object (i.e. its IConnectionPointContainer
object)
for a particular connection point instance identified
by the class of the event interface.
This allows one to ask for a particular connection point
rather than enumerating all of them via
getConnectionPoints
.
It is also necessary when getConnectionPoints
is not implemented by the particular COM object (e.g. Active X controls).
findConnectionPoint(obj, iid, expand = TRUE)
obj |
the COMIDispatch object in which to look for the connection point. This is the source of the events. |
iid |
the class identfier which specifies the particular event
interface of interest.
This can be a UUID (in string form and with the containing "{" and
"}", or alternatively an ITypeInfo object obtained
directly from the type library using the SWinTypeLibs
package.
The latter is currently used when converting the UUID from a string
to a CLSID (via the Microsoft API routine CLSIDFromString )
fails.
|
expand |
a logical value. If this is TRUE , the basic
IConnectionPoint-class is turned into a
IExpandedConnectionPoint-class and this
provides information about the UUID of the interface
needed to implement the methods for this connection point
and also the parent object associated with the connection point.
This information can then be used to simplify the connection
to the event source as the object becomes self-describing.
|
This calls FindConnectionPoint
in the Windows API.
An object of class IConnectionPoint-class
Duncan Temple Lang <duncan@wald.ucdavis.edu>
http://www.omegahat.org/RDCOMClient http://www.omegahat.org/RDCOMServer http://www.omegahat.org/SWinTypeLibs http://www.omegahat.org/SWinRegistry
getConnectionPoints
connectConnectionPoint
library(RDCOMClient) xls <- COMCreate("Excel.Application") xls[["Visible"]] <- TRUE xls[["Workbooks"]]$Add() sh1 <- xls[["Sheets"]]$Item(1) oles <- sh1[["OLEObjects"]] oleButton <- oles$Add(ClassType = "Forms.CommandButton.1", Top = 10, Left = 10, Width = 144, Height = 30) acx <- oleButton[["Object"]] acx[["Caption"]] <- "Compute Means" # Now find the connection point, i.e. the event source # that we can register with to receive events on the button. # Do this by looking in the type MSForms library library(SWinTypeLibs) formLib = LoadTypeLib("C:\\WINDOWS\\System32\\FM20.DLL") ## Not run: pt = findConnectionPoint(acx, formLib[["CommandButtonEvents"]]) # Now we have the event source, we create the handler. # See RDCOMServer. library(RDCOMServer) sinfo = createCOMEventServerInfo(formLib[["CommandButtonEvents"]], methods = list("Click"=function(...){cat("Hi from click\n")})) server = createCOMEventServer(sinfo) connectConnectionPoint(pt, server) ## End(Not run) xls$Quit()