I posted this once before, but the issue is still not solved. For some
reason the post, and all replies have been removed from this newgroup
already.
I am opening some Code windows from a VsPackage derived class with the
function IVsUIShellOpenDocument::OpenDocumentViaProject. I need to know when
that window is closed by the user. Iit is not a custom editor (I'm opening a
VB file) so I dont have any control over the editor.
Ed Dore replied and said to use the IVsWindowFrameNotify interface and set
the VSFPROPID_ViewHelper on the frame object. I've done this, but it does
not work. The callback is never made.
The OpenDocumentViaProject call returns an IVsWindowFrame object and this is
what I used to call SetProperty. It seems like it should work, but it
doesnt.
m_Frame.SetProperty((int)Microsoft.VisualStudio.Shell.Interop.__VSFPROPID.VS
FPROPID_ViewHelper,this);
Thanks,
Bill
"Ed Dore [MSFT]" - 02 Aug 2004 21:08 GMT
Hi Bill,
I'm having problems with this as well. Are you seeing an HRESULT of
0x80070057 indicating a bad parameter getting passed to SetProperty? I'm
currently trying to track down why this isn't working. Let me know if the
return value off of that SetProperty call is similar to mine. Note, I'm
just implementing IVsWindowFrameNotify and IVsWindowFrameNotify2 on my
package object, which is what the 'this' pointer is refering to below:
case PkgCmdIDList.cmdidBillTest:
{
Guid guidLogicalView = Guid.Empty;
IVsWindowFrame windowFrame;
IVsUIHierarchy vsHierarchy;
IOleServiceProvider sp;
uint itemID;
string fileName = "Form1.vb";
IVsUIShellOpenDocument uiShellOpenDoc =
(IVsUIShellOpenDocument)GetService(typeof(SVsUIShellOpenDocument));
int hr = uiShellOpenDoc.OpenDocumentViaProject(fileName, ref
guidLogicalView, out sp, out vsHierarchy, out itemID, out windowFrame);
if ( NativeMethods.Failed(hr) )
return hr;
windowFrame.Show();
hr = windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, this);
// FAILS WITH 0x80070057
break;
}
I'll post back on this thread when I figure out what I'm doing wrong.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 02 Aug 2004 22:09 GMT
Hi Bill,
I'm not sure if this is an interop problem yet, but I was able to get this
working by passing a new UnknownWrapper object as the 2nd parameter to
SetProperty.
For example:
Guid guidLogicalView = Guid.Empty;
IVsWindowFrame windowFrame;
IVsUIHierarchy vsHierarchy;
IOleServiceProvider sp;
uint itemID;
string fileName = "Form1.vb";
IVsUIShellOpenDocument uiShellOpenDoc =
(IVsUIShellOpenDocument)GetService(typeof(SVsUIShellOpenDocument));
int hr = uiShellOpenDoc.OpenDocumentViaProject(fileName, ref
guidLogicalView, out sp, out vsHierarchy, out itemID, out windowFrame);
if ( NativeMethods.Failed(hr) )
return hr;
windowFrame.Show();
// workaround for invalid argument problem
hr = windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, new
UnknownWrapper(this));
Note, you'll also have to implement both the IVsWindowFrameNotify and
IVsWindowFrameNotify2 on the object you're passing to the UnknownWrapper()
constructor.
In debugging the invalid parameter problem a bit more, it appears the
variant that IVsWindowFrame::SetProperty is getting, is a VT_I1. I'm not
sure as to why that's the case yet, but we're looking into it.
Do try the UnknownWrapper scenario and let me know if that doesn't work for
you.
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Bill Foust - 02 Aug 2004 23:27 GMT
Thanks so much Ed. You are exactly correct. I wasnt checking the return code
on the SetProperty call, but when I did, I saw the same error you did.
Adding the UnknownWrapper did the trick. Thanks for taking the time to
research it and come up with the simple solution.
Bill
> Hi Bill,
>
[quoted text clipped - 40 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.