>>>>>>Hi,
>>>>>>
>>>>>>This problem has started appearing in an old VFP app that uses VB UserControls from an OCX. This line of VB code errors at seemingly random intervals:
o.oref.LPrint (rMetahDC)
'o' is a reference to a VFP object that is passed by VFP as a parameter to the VB method containing the offending line.
>>>>>>'oref' is another VB object which is a control in the VFP object.
>>>>>>'rMetahDC' is a handle to a windows metafile created by the VB method.
>>>>>>I've checked that both 'o' and 'oref' are valid references before the line executes.
>>>>>>The .LPrint method executes without error and appears to return normally.
>>>>>>But the line itself raises an 'Automation Error' with the description 'The object invoked has disconnected from its clients'
>>>>>>Don't really know whether this error is a VB or VFP problem....
>>>>>>
>>>>>>Any suggestions?
>>>>>>TIA,
>>>>>>Viv
>>>>>
>>>>>Viv,
>>>>>
>>>>>Would this help - if you haven't tried it yet ?
>>>>>
>>>>>
http://support.microsoft.com/kb/966166>>>>>
>>>>>Try printing to another printer
>>>>
>>>>I suspected another printer but it didn't appear to be printer specific.
>>>>I've just changed the 'o.oref.LPrint (rMetahDC' line to 'o.oref.object.Lprint(rMetahDC)' and this old trick seems for some reason to have stopped the error - though I can't see why, in that case, it would have worked at all using the old code. FWIW the problem only seems to have arisen on machines with newer/faster hardware......
>>>
>>>
>>>Good you have it solved - things like that can turn into a nightmare
>>>
>>>If you suspect faster hardware, should it re-occur, maybe start playing with vfp.AutoYield. I have never had to touch AutoYield
>>
>>Thx. I'll bear in mind the Autoyield setting. My VFP is getting rustier by the day but I do recall having to use it somewhere else in this app to cure a problem.....
>
>
>I'm a bit surprised the 'object' trick did it - maybe it just appears to have done it
>
>Another thing that
may cure the problem is something like this
>
>xxx = o.oref && or o.oref.object
>xxx.LPrint (rMetahDC)
>
I can see that grabbing a local reference might keep it in scope.
I too was surprised that the '.object' trick seemed to work but I hammered it pretty hard and could not reproduce the problem after the change. I also passed the new build to the support guys and they also reported the problem has disappeared. So fingers crossed <g>