Answered by:
"Add as link" in custom project

Question
-
I've created a custom project type using a VSPackage. When using the Add Existing Item option in my custom project, the Add button doesn't have the splitter on it with the "Add" and "Add as Link" options like it does in a regular C# project. Is there a way to enable that for custom projects so that I can add files as links in the custom project?
EricTuesday, June 17, 2008 7:16 PM
Answers
-
I found that earlier. All it does is turn on the dropdown. It doesn't actually implement the feature. I've been tracing through the code and comparing the behavior with a C# project and I've got it mostly functioning now. I just need to implement support for cut/copy/paste and see if there's a way to draw the link icon and it'll be done. There are several changes throughout FileNode.cs, HierarchyNode.cs, ProjectNode.cs, and an addition to ProjectFileConstants.cs. So, if anyone wants the changes, contact me and I'll send them to you.
Eric
- Marked as answer by EWoodruff Thursday, June 19, 2008 7:36 PM
Thursday, June 19, 2008 7:36 PM
All replies
-
I guess you the c#-projectbase-class from the visual studio sdk.
So, I've bad news. It is just not implemented in this code and it is a lot of to do this.Wednesday, June 18, 2008 9:32 AM -
Yes, I'm using the MPF from the VS2008 SDK. I can't be the only one that wants this functionality and since the MPF appears to have been around for a while, you'd think somebody must have implemented it by now. If so, care to share? In the meantime, I've found a few bits of information and I'm looking into it myself as well. Lacking a reply here with info on how to do it, I'll post back with what I find.
Eric
Wednesday, June 18, 2008 7:26 PM -
This can be done by setting the __VSADDITEMFLAGS.VSADDITEM_ProjectHandlesLinks flag of grfAddFlags parameter passed to the AddProjectItemDlg method of IVsAddProjectItemDlg interface.
You can open the IronPython project sample in VSSDK and navigate to the AddItemToHierarchy virtual method in class HierarchyNode, and then modify it like this:
1182 if (addType == HierarchyAddType.AddNewItem)
1183 uiFlags = (uint)(__VSADDITEMFLAGS.VSADDITEM_AddNewItems |
1184 __VSADDITEMFLAGS.VSADDITEM_SuggestTemplateName |
1185 __VSADDITEMFLAGS.VSADDITEM_AllowHiddenTreeView);
1186 else
1187 uiFlags = (uint)(__VSADDITEMFLAGS.VSADDITEM_AddExistingItems |
1188 __VSADDITEMFLAGS.VSADDITEM_AllowMultiSelect |
1189 __VSADDITEMFLAGS.VSADDITEM_AllowStickyFilter
1190 | __VSADDITEMFLAGS.VSADDITEM_ProjectHandlesLinks);
1191 // Project adds items as links—'a1?enables Link menu item.
1192
1193 ErrorHandler.ThrowOnFailure(
1194 addItemDialog.AddProjectItemDlg(
1195 this.hierarchyId,
1196 ref projectGuid,
1197 project, uiFlags, null, null,
1198 ref strBrowseLocations, ref strFilter, out iDontShowAgain)); /*&fDontShowAgain*/
Then rebuild the whole solution, start VS under exp hive and create a IronPython project, invoke the “add existing item” dialog, you should be able to see the splitter on it with the "Add" and "Add as Link" options.
Hope this helps!
Thanks!
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Thursday, June 19, 2008 4:34 AM -
I found that earlier. All it does is turn on the dropdown. It doesn't actually implement the feature. I've been tracing through the code and comparing the behavior with a C# project and I've got it mostly functioning now. I just need to implement support for cut/copy/paste and see if there's a way to draw the link icon and it'll be done. There are several changes throughout FileNode.cs, HierarchyNode.cs, ProjectNode.cs, and an addition to ProjectFileConstants.cs. So, if anyone wants the changes, contact me and I'll send them to you.
Eric
- Marked as answer by EWoodruff Thursday, June 19, 2008 7:36 PM
Thursday, June 19, 2008 7:36 PM -
Hi EWoodruff,
Can you sand me the updated files with changes required to enable Link functionality?
My email:
michaelk@front.ru
Thanks,
Michael.Wednesday, June 25, 2008 8:34 AM -
Hi!
I realize that this thread is almost 5 years old, but nonetheless I was wandering if there are any updates on this issue? Do you still have to make it on your own, or do the new versions of MPF already support the "add as link" feature. If so, how to enable?
Regards,
Max
Monday, March 25, 2013 1:51 PM -
The MPF 2012 code is not that much different from the MPF 2010 code including the lack of "standard" features and fixes for reported bugs in the 2010 version. Most of the changes are related to allowing the MPF stuff to run in a thread-safe manner in Visual Studio 2012. In order to get my project working in both VS2010 and VS2012 without having separate versions for each I ended up merging the changes from the MPF 2012 version into my copy of the 2010 version.
My version contains the above noted patches to allow adding files as a link, fixes to the cut/copy/paste and several other fixes, and a complete implementation for Show All Files. If anyone wants it, you can download it as part of the source code for the SHFB project on CodePlex. You'll find it in the SHFB\Source\MPFProj_2010 folder. It is available here: http://shfb.codeplex.com/SourceControl/list/changesets
Eric
- Proposed as answer by f_max Tuesday, March 26, 2013 7:56 AM
Monday, March 25, 2013 7:32 PM