Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2004

Tip: Looking for answers? Try searching our database.

Detecting a window closing (second time)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Foust - 02 Aug 2004 17:21 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.