Dispatch [message #81521] |
Fri, 28 September 2012 04:45 |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi,
I'm trying to test a call to a COM object and I'm finding out that life is not as easy as it might seem.
First problem is:
If I call the following line:
IDL_Object = OBJ_NEW('IDLCOMIDispatch$PROGID$RSIDemoComponent.RSIDemoObj1 ')
inside a procedure in IDL 8.2 (32-bit) I get the desired object. I'm actually running IDispatchDemo demo of IDL.
If I call the same inside a widget application, I get a limited result with only two objects being displayed. Here is the output that is put in a text widget containing executed command (using CALL_FUNCTION()), output of the help on the object and the IDL version:
ExecutedCommand> IDL_Object = OBJ_NEW('IDLCOMIDispatch$PROGID$RSIDemoComponent.RSIDemoObj1 ')
** Object class IDLCOMIDISPATCH$PROGID$RSIDEMOCOMPONENT.RSIDEMOOBJ1, 1 direct superclass, 2 known methods
Superclasses:
IDLCOMIDISPATCH <Direct>
Known Function Methods:
IDLCOMIDISPATCH$PROGID$RSIDEMOCOMPONENT.RSIDEMOOBJ1::INIT
Known Procedure Methods:
IDLCOMIDISPATCH$PROGID$RSIDEMOCOMPONENT.RSIDEMOOBJ1::CLEANUP
** Structure !VERSION, 8 tags, length=76, data length=76:
ARCH STRING 'x86'
OS STRING 'Win32'
OS_FAMILY STRING 'Windows'
OS_NAME STRING 'Microsoft Windows'
RELEASE STRING '8.2'
BUILD_DATE STRING 'Apr 10 2012'
MEMORY_BITS INT 32
FILE_OFFSET_BITS
INT 64
Below is the code I used to test this. Before you can get it to work, you have to make sure you installed the RSIDemoComponent.dll (the instructions are on page 23 of the bridges.pdf in the help directory).
If I run the code below I get the results shown above. If I run the first line of IDispatchDemo.pro I get all the methods displayed.
Anybody have a clue why this is working differently?
Cheers,
Helder
pro TestUviewConnection_ExecuteCommand, Event
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, Cancel=1
Help, /Last_Message, Output=traceback
WIDGET_CONTROL, info.wResult, SET_VALUE = traceback, /APPEND
BEEP
RETURN
ENDIF
WIDGET_CONTROL, Event.top, Get_UValue=info
WIDGET_CONTROL, info.wTextInput, GET_VALUE=InputString
ExecutedCommand = 'ExecutedCommand> IDL_Object = OBJ_NEW('''+InputString+''')'
WIDGET_CONTROL, info.wResult, SET_VALUE = ExecutedCommand
IDL_Object = CALL_FUNCTION('OBJ_NEW',InputString)
ExecutedCommand = 'ExecutedCommand> IDL_Object = OBJ_NEW('''+InputString+''')'
HELP, IDL_Object, /OBJECTS, OUTPUT=HelpResult
OBJ_DESTROY, IDL_Object
HELP, !version, OUTPUT=VersionHelpResult
ResultText = [ExecutedCommand,'',HelpResult,'',VersionHelpResult]
WIDGET_CONTROL, info.wResult, SET_VALUE = ResultText
end
pro TestUviewConnection_event, Event
wTarget = (widget_info(Event.id,/NAME) eq 'TREE' ? $
widget_info(Event.id, /tree_root) : event.id)
wWidget = Event.top
case wTarget of
Widget_Info(wWidget, FIND_BY_UNAME='ExecuteButton'): $
if( Tag_Names(Event, /STRUCTURE_NAME) eq 'WIDGET_BUTTON' ) then TestUviewConnection_ExecuteCommand, Event
Widget_Info(wWidget, FIND_BY_UNAME='TextInput'): $
if( Tag_Names(Event, /STRUCTURE_NAME) eq 'WIDGET_TEXT_CH' ) then TestUviewConnection_ExecuteCommand, Event
ELSE: PRINT, 'Nothing to do'
endcase
end
PRO TestUviewConnection
wBase = WIDGET_BASE(TITLE='Test Connection', /COLUMN, XPAD=10, YPAD=5, UVALUE=info)
LabelVal = ['Examples:',$
'IDLCOMIDispatch$PROGID$RSIDemoComponent.RSIDemoObj1',$
'IDLCOMIDispatch$CLSID$08FB8C19_5C78_4EF5_99B4_9EA009552A33' ,$
'',$
'Either use IDLCOMIDispatch$PROGID$... or IDLCOMIDispatch$CLSID$...']
wLabelEx = WIDGET_TEXT( wBase, XSIZE=100, YSIZE=8, UNAME='TextExample', VALUE=LabelVal)
wTextInput = WIDGET_TEXT( wBase, /EDITABLE, XSIZE=100, UNAME='TextInput', VALUE='IDLCOMIDispatch$PROGID$RSIDemoComponent.RSIDemoObj1')
wButton = WIDGET_BUTTON(wBase, VALUE='Execute',UNAME='ExecuteButton')
wResult = WIDGET_TEXT( wBase, EDITABLE=0, YSIZE=40, UNAME='TextOutput', VALUE='', /SCROLL)
info = {wBase:wBase ,$
wTextInput:wTextInput ,$
wButton:wButton ,$
wResult:wResult}
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, wBase, SET_UVALUE=info, /No_Copy
XMANAGER, 'TestUviewConnection', wBase, $
EVENT_HANDLER = 'TestUviewConnection_event', $
/NO_BLOCK
RETURN
END
|
|
|