Yong-Woong Kim wrote:

>Hi, gurus!
>
> Now I am developing a Curl applet that it can communicate an ActiveX control. 
> My curl applet have to do something in response to events from the ActiveX 
> Control.
>
> When I created an instance of the ActiveX control with the class 
> ActiveXObject, I could use its methods and fields, but I couldn't know how I 
> could receive events from it.
>
> In case of Javascrpt or VBScript, I can receive events of an ActiveX control 
> like this;
>
><SCRIPT language="VBScript or Javascript" for="ActiveXControlName" 
>event="eventName(Parameter1, Parameter2, ...)">
>
>The codes in Javascript or VBScript that are run when the event fire is 
>located here...
>
><SCRIPT>
>
> Like that, can the Curl applets receive events from ActiveX controls? If it 
> can do so, how can I get it?
>
>- Yong 
>  
>

Here is some information about ActiveX and Curl, which is not in the
Curl documentation.

COM (ActiveX) method calls are always synchronous.

The answer to the question "will the applet be responsive while it's
waiting for the ActiveX method to return?" is "not normally", but there
could be some cases where strange things happen e.g. if the ActiveX
method itself enters a message loop or if the ActiveX is in a different
host process (like with Excel ).

Some ActiveX controls, such as Quicktime or Excel, support event-like
behavior. I am attaching some code which is adapted from a test we run.
It shows you how events are used with an Excel ActiveX object. I will
also attach the spreadsheet used by the test, and the output we see from
the test.

When ActiveX calls our event handler and there is some error (e.g.
argument mismatch or anything), we convert the exception to the ActiveX
error code and return (like we are supposed to; we can't throw an
exception back to ActiveX). But most ActiveXs do not bother checking the
results of events, so usually you get no error message and you don't
know why your event didn't get called. Of course this is fixable if you
have control of the ActiveX code. And it's not a Curl specific problem.


-- Duke



Attachment: worksheet.xls
Description: MS-Excel spreadsheet

Excel started
m:\activex\worksheet.xls
excel-app=[Win32XObj @0x072E84A8]
getters of [Win32XObj @0x072E84A8]
Application
Creator
Parent
ActiveCell
ActiveChart
ActiveDialog
ActiveMenuBar
ActivePrinter
ActiveSheet
ActiveWindow
ActiveWorkbook
AddIns
Assistant
Cells
Charts
Columns
CommandBars
DDEAppReturnCode
DialogSheets
MenuBars
Modules
Names
Range
Rows
Selection
Sheets
ShortcutMenus
ThisWorkbook
Toolbars
Windows
Workbooks
WorksheetFunction
Worksheets
Excel4IntlMacroSheets
Excel4MacroSheets
AlertBeforeOverwriting
AltStartupPath
AskToUpdateLinks
EnableAnimations
AutoCorrect
Build
CalculateBeforeSave
Calculation
Caller
CanPlaySounds
CanRecordSounds
Caption
CellDragAndDrop
ClipboardFormats
DisplayClipboardWindow
ColorButtons
CommandUnderlines
ConstrainNumeric
CopyObjectsWithCells
Cursor
CustomListCount
CutCopyMode
DataEntryMode
_Default
DefaultFilePath
Dialogs
DisplayAlerts
DisplayFormulaBar
DisplayFullScreen
DisplayNoteIndicator
DisplayCommentIndicator
DisplayExcel4Menus
DisplayRecentFiles
DisplayScrollBars
DisplayStatusBar
EditDirectlyInCell
EnableAutoComplete
EnableCancelKey
EnableSound
EnableTipWizard
FileConverters
FileSearch
FileFind
FixedDecimal
FixedDecimalPlaces
Height
IgnoreRemoteRequests
Interactive
International
Iteration
LargeButtons
Left
LibraryPath
MailSession
MailSystem
MathCoprocessorAvailable
MaxChange
MaxIterations
MemoryFree
MemoryTotal
MemoryUsed
MouseAvailable
MoveAfterReturn
MoveAfterReturnDirection
RecentFiles
Name
NetworkTemplatesPath
ODBCErrors
ODBCTimeout
OnCalculate
OnData
OnDoubleClick
OnEntry
OnSheetActivate
OnSheetDeactivate
OnWindow
OperatingSystem
OrganizationName
Path
PathSeparator
PreviousSelections
PivotTableSelection
PromptForSummaryInfo
RecordRelative
ReferenceStyle
RegisteredFunctions
RollZoom
ScreenUpdating
SheetsInNewWorkbook
ShowChartTipNames
ShowChartTipValues
StandardFont
StandardFontSize
StartupPath
StatusBar
TemplatesPath
ShowToolTips
Top
DefaultSaveFormat
TransitionMenuKey
TransitionMenuKeyAction
TransitionNavigKeys
UsableHeight
UsableWidth
UserControl
UserName
Value
VBE
Version
Visible
Width
WindowsForPens
WindowState
UILanguage
DefaultSheetDirection
CursorMovement
ControlCharacters
EnableEvents
DisplayInfoWindow
ExtendList
OLEDBErrors
COMAddIns
DefaultWebOptions
ProductCode
UserLibraryPath
AutoPercentEntry
LanguageSettings
Dummy101
AnswerWizard
CalculationVersion
ShowWindowsInTaskbar
FeatureInstall
workbooks=[Win32XObj @0x072E8580]
Expected:
old value is 3, type is float
Actual:
as=[Win32XObj @0x072E8730]
methods of [Win32XObj @0x072E8730]
QueryInterface
AddRef
Release
GetTypeInfoCount
GetTypeInfo
GetIDsOfNames
Invoke
Activate
Copy
Delete
Move
_PrintOut
PrintPreview
Protect
SaveAs
Select
Unprotect
Arcs
SetBackgroundPicture
Buttons
Calculate
ChartObjects
CheckBoxes
CheckSpelling
ClearArrows
Drawings
DrawingObjects
DropDowns
Evaluate
_Evaluate
ResetAllPageBreaks
GroupBoxes
GroupObjects
Labels
Lines
ListBoxes
OLEObjects
OptionButtons
Ovals
Paste
PasteSpecial
Pictures
PivotTables
PivotTableWizard
Rectangles
Scenarios
ScrollBars
ShowAllData
ShowDataForm
Spinners
TextBoxes
ClearCircles
CircleInvalid
PrintOut
_CheckSpelling
getters of [Win32XObj @0x072E8730]
Application
Creator
Parent
CodeName
_CodeName
Index
Name
Next
OnDoubleClick
OnSheetActivate
OnSheetDeactivate
PageSetup
Previous
ProtectContents
ProtectDrawingObjects
ProtectionMode
ProtectScenarios
Visible
Shapes
TransitionExpEval
AutoFilterMode
EnableCalculation
Cells
CircularReference
Columns
ConsolidationFunction
ConsolidationOptions
ConsolidationSources
DisplayAutomaticPageBreaks
EnableAutoFilter
EnableSelection
EnableOutlining
EnablePivotTable
FilterMode
Names
OnCalculate
OnData
OnEntry
Outline
Range
Rows
ScrollArea
StandardHeight
StandardWidth
TransitionFormEntry
Type
UsedRange
HPageBreaks
VPageBreaks
QueryTables
DisplayPageBreaks
Comments
Hyperlinks
_DisplayRightToLeft
AutoFilter
DisplayRightToLeft
Scripts
range=[Win32XObj @0x072E80DC]
old value is 3, type is double
Expected:
12
Actual:
12
SheetChange event called
Sh=[Win32XObj @0x072E8730], Target=[Win32XObj @0x072E8808]
Expected:
9
Actual:
9
WorkbookBeforeClose event called
Wb=[Win32XObj @0x072E8658], Cancel=false
Excel started
Excel started
Excel started
Excel started
{curl 3.0  applet}

||| TESTS EXCEL CONNECTION.

{import * from CURL.GRAPHICS.ACTIVEX}

|| set to false when creating Excel; true when modified.
{let change-reported?:bool=false}

{define-proc {start-excel-up}:ActiveXObject
    let excel-app:#ActiveXObject
    set change-reported?=false
    {try
        set excel-app =
            {ActiveXObject
                ProgId = "excel.application",
                WorkbookBeforeClose=
                {proc {Wb:ActiveXObject, Cancel:bool}:void
                    {output "WorkbookBeforeClose event called"}
                    {dump Wb, Cancel}
                },
                SheetChange=
                {proc {Sh:ActiveXObject, Target:ActiveXObject}:void
                    {output "SheetChange event called"}
                    {dump Sh, Target}
                    set change-reported? = true
                }
            }
        {output "Excel started"}
     catch e:ActiveXNotFoundException do
        {output "Can't do active-x test since Excel is not on this machine."}
        {exit 0}
    }
    {return {non-null excel-app}}
}

{define-proc {dump-getters obj:ActiveXObject}:void
    {output "getters of ", obj}
    {for i = 0 below obj.getter-count do
        let info:ActiveXFieldInfo = {obj.get-getter-info i}
        {output info.name}
    }
}

{define-proc {dump-methods obj:ActiveXObject}:void
    {output "methods of ", obj}
    {for i = 0 below obj.method-count do
        let info:ActiveXMethodInfo = {obj.get-method-info i}
        {output info.name}
    }
}

{define-proc {main}:int
    let sample-cell:String="A1"
    let sum-cell:String="A4"
    let excel-file-url:Url = {url "worksheet.xls"}

    let excel-app:ActiveXObject = {start-excel-up}
    {try
        {output excel-file-url.local-filename}
        {dump excel-app}
        {dump-getters excel-app}
        let workbooks:ActiveXObject = excel-app.Workbooks
        {dump workbooks}

        {workbooks.Open excel-file-url.local-filename}
        {output "Expected:"}
        {output "old value is 3, type is float"}
        {output "Actual:"}
        let as:ActiveXObject = excel-app.ActiveSheet
        {dump as}

        {dump-methods as}
        {dump-getters as}

        let range:ActiveXObject = {as.Range sample-cell}
        {dump range}

        let old-value:any = range.Value
        {output {format "old value is %s, type is %s", old-value, {type-of old-value}}}
        {output "Expected:"}
        {output 12}
        {output "Actual:"}
        {output {as.Range sum-cell}.Value}
        {assert {as.Range sum-cell}.Value == 12}
        {assert not change-reported?}
        set {as.Range sample-cell}.Value = 0
        {assert change-reported?}
        {assert {as.Range sum-cell}.Value == 9}
        {output "Expected:"}
        {output 9}
        {output "Actual:"}
        {output {as.Range sum-cell}.Value}

     finally
        set excel-app.ActiveWorkbook.Saved = true
        {excel-app.Quit}
    }

    || just try creating it again in the same thread
    set excel-app = {start-excel-up}
    {excel-app.Quit}
    set excel-app = {start-excel-up}
    {excel-app.Quit}
    set excel-app = {start-excel-up}
    {excel-app.Quit}
    set excel-app = {start-excel-up}
    {excel-app.Quit}

    {return 0}
}

{main}

*******************************************
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]

Reply via email to