Re: EuCom - Matt Lewis
Matt Lewis wrote:
>
> Jonas Temple wrote:
> >
> > Matt,
> >
> > Really trying hard now to use some ActiveX/COM controls and have a question:
> >
> > If an object has another object as one of it's properties and I need to
> > put the "child" object into the "parent" object, how should this be done?
>
> Assuming that you are able to use the IDispatch interface by calling
> invoke(), you probably need to set the property. It would probably look
> something like this (assuming you're using a wrapper generated by
> tbrowse):
>
> void = invoke( anObject, {anObject_p_SomeObject, DISPID_PROPERTYPUT},
> {someObject}, {VT_UNKNOWN}, DISPATCH_PROPERTYPUT )
>
> You might need to use DISPATCH_PROPERTYPUTREF instead--I've never entirely
> figured out which gets used when. I generally go by trial and error.
>
> Do you have any documentation on the object? Some example VB or C++ code
> would be helpful. There is some information in the faq that talks about
> porting VB and C++ that might be helpful.
>
> Matt Lewis
>
Matt,
Well, glad to know I wasn't far off! Here's my code thus far:
include cwbx.ew
with trace
without warning
integer cwb_cmd, as400_system, errors
atom void, sys_ptr, ptr, err_count
com_err_out(1)
trace(1)
cwb_cmd = create_com_object( Command_clsid_ix )
as400_system = create_com_object( AS400System_clsid_ix )
sys_ptr = allocate_string(ansi_to_unicode("DILBERT.MKG.COM"))
void = invoke(as400_system,
{AS400System_m_Define},{sys_ptr},{VT_BSTR},DISPATCH_METHOD)
void = invoke(cwb_cmd, {Command_p_system,DISPID_PROPERTYPUT},{as400_system},
{VT_UNKNOWN},DISPATCH_PROPERTYPUT)
ptr = allocate_string(ansi_to_unicode("SNDMSG MSG('This is a test')
TOUSR(JOTEMPL)"))
void = invoke(cwb_cmd, {Command_m_Run},{ptr},{VT_BSTR},DISPATCH_METHOD)
errors = ref_com_object(Errors_clsid_ix, invoke(cwb_cmd, {Command_p_Errors}, {},
{},
DISPATCH_PROPERTYGET))
err_count = invoke(errors, {Errors_p_Count}, {}, {}, DISPATCH_PROPERTYGET)
free(sys_ptr)
free(ptr)
release_com()
What this program is attempting to do is connect to an AS400 and execute
a command to send me a message.
The problem I'm having is with the as400_system object. I set the system
name correctly but the problem comes up when I try to set the
as400_system object in the cwb_cmd object. I get a "Member not found"
error message. I also tried you suggestion of DISPATCH_PROPERTYPUTREF
and I got a machine exception.
Here's the sample VB code from the documentation:
' Declare variables
Dim systemNames As New cwbx.systemNames
Dim as400 As New cwbx.AS400System
Dim cmd As New cwbx.Command
' Retrieve the default system and use it to initialize the AS400System
' object
as400.Define systemNames.DefaultSystem
' Set the System property of the command object
Set cmd.System = as400
In the cwbx.ew that tbrowse created the property comments for the
Command_p_system has a type of IcwbxSystem instead of the usual VT_xxxx
value. Don't know if that has anything to do with it. I could send you
the cwbx.ew file, if that would help.
The end result of this is when I try to run the command I get a "Value
for property System not correct". Lots of help there...
Thanks for your help, I really want to try and get this working!
Jonas
|
Not Categorized, Please Help
|
|