Re: How to Passs NULL as a IDispatch Pointer to method?
Yingpu Zhao wrote: > Thanks to Larry. > I want to pass the IDispatch pointer of other COM object to > AddShapeInfo or pass null to tell x do nothing. > for example. > > Rect= Dispatch("Rect.Document") > ShapeSet = Dispatch("xxx.Document") > ShapeSet.AddShapeInfo("Rect", 0, Shape) > > or > > ShapeSet.AddShapeInfo("EmptyShape", 0, None) > I think you will need to pass a basically empty class that is wrapped in an IDispatch object. See my earlier example. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Passs NULL as a IDispatch Pointer to method?
Thanks to Larry. I want to pass the IDispatch pointer of other COM object to AddShapeInfo or pass null to tell x do nothing. for example. Rect= Dispatch("Rect.Document") ShapeSet = Dispatch("xxx.Document") ShapeSet.AddShapeInfo("Rect", 0, Shape) or ShapeSet.AddShapeInfo("EmptyShape", 0, None) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Passs NULL as a IDispatch Pointer to method?
[EMAIL PROTECTED] wrote: > Hello,all > I am using win32com to use com. and invoke a method as follows: > void AddShapeInfo(LPCTSTR name, LONG type, IDispatch* pDisp); > but i pass 0 or None to third parameter and get error info: > x.AddShapeInfo("who", 10, 0) > > Traceback (most recent call last): > File "", line 1, in > x.AddShapeInfo("who", 10, 0) > File "", line 2, in AddShapeInfo > com_error: (-2147352571, 'Type mismatch.', None, 3) > > or > x.AddShapeInfo("who",0,None) > > Traceback (most recent call last): > File "", line 1, in > x.AddShapeInfo("who",0,None) > File "", line 2, in AddShapeInfo > com_error: (-2147352571, 'Type mismatch.', None, 3) > Maybe Mark Hammond will chime in here, but I'll make at least an attempt to help. If I'm reading this correctly the 3rd argument should be and pointer to an IDispatch object. Passing null or zero wouldn't make any sense. This looks like a pointer to a callback function for this shape. To get one you would need to define a Python COM class and wrap it with win32com.server.util.wrap() possibly something like: class who: _public_methods_=['somemethod'} # # I don't know what method AddShapeInfo is going to call so # change this to the appropriate method. # def somemethod(self): # # Put this method's code here # pass # # In your program # id=win32com.server.util.wrap(who()) x.AddShapeInfo("who",0,id) I could be way off base here, but I hope that this helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list
How to Passs NULL as a IDispatch Pointer to method?
Hello,all I am using win32com to use com. and invoke a method as follows: void AddShapeInfo(LPCTSTR name, LONG type, IDispatch* pDisp); but i pass 0 or None to third parameter and get error info: >>> x.AddShapeInfo("who", 10, 0) Traceback (most recent call last): File "", line 1, in x.AddShapeInfo("who", 10, 0) File "", line 2, in AddShapeInfo com_error: (-2147352571, 'Type mismatch.', None, 3) or >>> x.AddShapeInfo("who",0,None) Traceback (most recent call last): File "", line 1, in x.AddShapeInfo("who",0,None) File "", line 2, in AddShapeInfo com_error: (-2147352571, 'Type mismatch.', None, 3) -- http://mail.python.org/mailman/listinfo/python-list