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 2005

Tip: Looking for answers? Try searching our database.

Property page dialog from file context menu in solution explorer?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don B. - 09 Aug 2005 23:05 GMT
[another property page question...]

In VC++, you can use the file context menu in solution explorer to select
"Properties" and invoke the Property Page Dialog, with all the property pages
that apply to the file.  I'd like to implement similar functionality in a new
project type derived from the MyC VSIP EnvSDK sample.

Using a naive approach, I added support for ISpecifyPropertyPages to the
CFileVwFileNode class, but GetPages() was not called by the framework.  The
documentation says that property pages are only created for objects returned
via IVsCfgProvider2.  This interface maps configuration objects (e.g.
CMyProjectCfg) to configurations (e.g. Debug|Win32) in a 1:1 correspondence.

So how can I duplicate the functionality of VC++ described?

Note that the Properties Window is inadequate for my needs, since I have
multiple property pages for each file.

thanks
--Don
"Gary Chang[MSFT]" - 10 Aug 2005 10:46 GMT
Hi Don,

Currently, we are looking into this problem. We will reply here with more
information as soon as possible.
If you have any more concerns on it, please feel free to post here.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 10 Aug 2005 23:36 GMT
Hi Don,

What version of VS .Net are you targeting with this package? (just curious,
as I may need to mangle the appropriate MyC sample to confirm some of this).

This functionality is actually provided through the
cmdidPropSheetOrProperties command, which is handled by the IDE. The shell
calls an internal function called PageFrameCanShowPropertyPages and if this
fails, drops down into the cmdidPropertyPages case which simply displays
the properties dialog.

If memory serves, this PageFrameCanShowPropertyPages uses a global object
that's populated by the IDE's selection state. And if I recall correctly,
that code actually relies upon there being a valid browse object for the
selected hierarchy item(s).  Additionally, there is a pretty nasty bug in
VC 2003 that may require you to pass that VSHPROPID_BrowseObject  as an
IUnknown pointer instead of an IDispatch pointer.  For example:

  // CVsHierarchy::GetProperty (hyarchy.cpp) workaround for crashing
problem invoking Properties dialog with multiple items selected.

   case VSHPROPID_BrowseObject:        // CHierNode derived property
       // if the node is the root node check if CVsHierarchy object
implements IDispatch
//        if (pNode->GetVsItemID() == VSITEMID_ROOT && SUCCEEDED(hr =
this->QueryInterface(IID_IDispatch, (void **)&V_DISPATCH(pvar))))
       if (pNode->GetVsItemID() == VSITEMID_ROOT && SUCCEEDED(hr =
this->QueryInterface(IID_IUnknown, (void **)&V_DISPATCH(pvar))))
       {
//            V_VT(pvar) = VT_DISPATCH;
                V_VT(pvar) = VT_UNKNOWN;
         }
       else
       {   // reclear the variant
           ::VariantInit(pvar);
           if (FAILED(hr = pNode->GetProperty(propid, pvar)))
               hr = E_NOINTERFACE;
       }
       break;

I ran into this a few months ago with another customer, so in addition to
ensuring your hierarchy item supports that VSHPROPID_BrowseObject property,
you migth want to modify the hierutil7 codebase with the above workaround
if you're targeting VS 2003.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Don B. - 11 Aug 2005 01:51 GMT
Ed,

Thanks for the info.  We are targeting VS2005, so hopefully that will make
things simpler.  Your reply sounds promising, but it looks like I have some
studying up to do before I understand it completely.

thanks
--Don

> Hi Don,
>
[quoted text clipped - 45 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.
Don B. - 12 Aug 2005 18:30 GMT
Ed,

Sorry if I'm a little slow to catch on here...all of the samples I've been
looking at for my project system (MyC, Figures, BscPrj) use the same code in
CFileVwFileNode::GetProperty(), basically:

   case VSHPROPID_BrowseObject:        // CHierNode derived property
        if(SUCCEEDED(hr =
                      QueryInterface(IID_IDispatch, (void
**)&V_DISPATCH(pvar))))
        {
            V_VT(pvar) = VT_DISPATCH;
        }
        break;

Just to be very explicit about what I want to do and what happens: when I
right-click on a source file in solution explorer to get the context menu,
then select "Properties", it executes the code above successfully.  If I
implement the ISpecifyPropertyPages interface as part of CFileVwFileNode,
GetPages() is not called and focus still just changes to the properties
window (as opposed to getting the properties dialog box with multiple pages).

The sample code you provided was for VS2003, and I am working with VS2005,
so I assume I don't need the IUnknown workaround.  However, the code you
provided also checked for "root node" and referenced another node, "pNode".  
Since I want the properties for a specific file, I don't want the root node,
correct?  I'm not sure what "pNode" should or could refer to.

I tried some various permutations of your code, including returning
IUnknown, but didn't see any change in behavior.

It seems like I'm just missing some basic connection here...the VSIP
documentation says property pages are only created for objects returned
via IVsCfgProvider2, which the file object is not.

I basically want it to work like VC++ when you right-click on a C++ source
file, select properties, and get the dialog box with all the C/C++ property
pages.

Any ideas?

thanks
--Don

> > Hi Don,
> >
[quoted text clipped - 45 lines]
> >
> > This post is 'AS IS' with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 12 Aug 2005 23:14 GMT
Hi Don,

The code I sent was actually from a mangled MyC sample targeting VS 2003,
and we were actually attempting to display the project properties dialog
via that command from the classview. Which is basically why we were looking
for the root project node. Sorry about that. I understand exactly what
you're trying to do, so no worries there. I need to dig a bit deeper into
that sample as well as the C++ hierarchy implementation to figure out
what's going wrong here. Will respond back on this thread as soon as I have
an opportunity to do so.

You shouldn't need that IUnknown workaround for VS 2005, but I'm not sure
if the fix made it in before Beta2 or not. Will give this a shot myself and
let you know what all is required, after I dig through the C++ hierarchy
implementation.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 17 Aug 2005 22:49 GMT
Hi Don,

Please disregard my previous posts on this topic. That info was actually in
references to a different issue where we were attempting to invoke the
property frame dialog from the classview.

To invoke the property frame via the Properties (actually the
cmdidPropSheetOrProperties command), the hierarchy node in question must
implement either ISpecifyPropertyPages, or IVsCfgProvider2, which in turn
provides an object implementing IVsCfg that also implements
ISpecifyPropertyPages.

Using Whidbey Beta2 with the matching VSIP SDK, I was able to get this
dialog invoked, by implementing ISpecifyPropertyPages on the
CFileVwFileNode class. You mentioned that you were not seeing the GetPages
method getting called, which leads me to suspect you didn't add an entry
for this interface in your COM map.

Regarding the reference to IVsCfgProvider2, I believe this is in reference
to whether or not the properties associated with the object ( in this case
the file ) are stored in a per configuration basis. For example, the build
options for a specific file may differ between debug and release
configurations. In the case of the C++ project system, we actually
implement IVsCfgProvider2 on the C++ hierarchy object representing the
file, along with IVsPerPropertyBrowsing, IPerPropertyBrowsing and
IVsExtensibleObject.

Here's the modifications I made to the MyC sample to allow for the
PropertyFrame to display:

PrjNFile.h

class CFileVwFileNode :
  public CFileVwBaseNode,
   public IConnectionPointContainerImpl<CFileVwFileNode>,
   public IPropertyNotifySinkCP<CFileVwFileNode>,
  public IDispatchImpl<IMyCPrjProjHierItemProps,
&IID_IMyCPrjProjHierItemProps, &LIBID_MyCPrjPKGLib>,
  public ISpecifyPropertyPages
{
  friend CMyProjectHierarchy;
  friend CFileVwProjNode;

  ........

   BEGIN_COM_MAP(CFileVwFileNode)
      COM_INTERFACE_ENTRY(IMyCPrjProjHierItemProps)
      COM_INTERFACE_ENTRY(IDispatch)
      COM_INTERFACE_ENTRY(IConnectionPointContainer)
      COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
   END_COM_MAP()

  .........

  // ISpecifyPropertyPages
  public:
     STDMETHOD(GetPages)(CAUUID* pPages);
       .........
};

PrjNFile.cpp

HRESULT CFileVwFileNode::GetPages(CAUUID* pPages)
{
  pPages->cElems = 3;
  pPages->pElems = (GUID*)CoTaskMemAlloc(pPages->cElems * sizeof(GUID));
  if (!pPages->pElems)
     return E_OUTOFMEMORY;

  pPages->pElems[0] = CLSID_StockFontPage;
  pPages->pElems[1] = CLSID_StockColorPage;
  pPages->pElems[2] = CLSID_StockPicturePage;

  return S_OK;
}

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Don B. - 19 Aug 2005 22:33 GMT
Ed,

As with my get_CategoryTitle() problem from Aug 5th, fixing my COM map made
the property page dialog appear.  Thank you.  (At least I'm consistent in my
errors.)

From your explanation I think I need an implementation more like the one you
describe for VC++, but without solving this issue I wouldn't have gotten very
far!  

thanks
--Don

> Hi Don,
>
[quoted text clipped - 76 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.
Ed Dore [MSFT] - 20 Aug 2005 05:12 GMT
You're more than welcome Don. You did all the legwork on both those issues.
I just followed the blueprint you layed out. Based on the description of
what you did, it was basically the only thing I could think of  :-)

Ed Dore [MSFT]
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.