If , for any reason, you need to do this with already existing libraries, this post will be no good for you but don't worry, because in some of the next posts, I will explain a cool method to do this as well.
1. Create a list definition to start from
First we need some kind of list definition to start from. Most of the time I use the SharePoint Solution Generator to generate a solution with the list definition files in it. So just create your list in the GUI and create a list definition with this tool.
2. Discovering the templates
All templates for rendering the toolbars found in any list in SharePoint, can be found in the defaulttemplates.aspx file which is located in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES folder.
To check which template your list definition is using, search for the property "ToolbarTemplate".
3. Creating your own control template
- Copy the defaulttemplates.ascx and place it in the same location C:\Program Files\Common Files\Microsoft Shared\webserverextensions\12\TEMPLATE\CONTROLTEMPLATES. You can give any custom name to the ascx file.
- Remove all the rendering templates from the custom defaulttemplates.ascx except the “DocumentLibraryViewToolbar”. Change the ID to a custom name like “MyCustomViewToolbar”.
- Remove the "SharePoint: UploadMenu" control rendering from the template and save the custom defaulttemplates.ascx. Of course you can delete other control renderings if you want to hide other buttons as well.
- Open the schema.xml file of your list definition you just created and in the default view (BaseViewId=1) add the “ToolbarTemplate” attribute which mentions your custom rendering template created without the upload menu. This XML snippet could look something like this:
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" ToolbarTemplate="MyCustomViewToolbar" DisplayName="$Resources:core,All_Documents;" DefaultView="TRUE" MobileView="True" MobileDefaultView="True" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/dlicon.png" Url="Forms/AllItems.aspx"><!-- _locID@DisplayName="camlidDc1" _locComment=" " --> - Save your changes, install and activate the feature for your custom list defintion and you're good to go. If all goes well you will see your template end up in the collection of possible list templates when you want to create a new list.