Category Archives: Ribbon

Windows Ribbon for WinForms in Visual Studio 2015

The same solution is still working for Visual Studio 2015. Please ensure that the registry keys must be changed to support VS 2015.

https://bernhardelbl.wordpress.com/2013/11/26/windows-ribbon-for-winforms-in-visual-studio-2013/

Advertisements

Windows Ribbon for WinForms in Visual Studio 2013

The Windows Ribbon project is still working in Visual Studio 2013. Now I will show you the steps I did to get it working.

Download and install Windows 8.1 SDK

Windows 7 SDK is also enough.

Bild 156

Download the Latest Ribbon Sources

http://windowsribbon.codeplex.com/SourceControl/latest

Bild 152

Get the RibbonGenerator compiling

The download is below. You do not need this.

Bild 153

Microsoft.VisualStudio.Shell not found?

Bild 154 Bild 155

 Download Visual Studio 2013 SDK

Bild 157

Bild 158

Bild 159

Switch the target of the RibbonGenerator

Bild 160

Bild 161

Now it should compile.

Download the Ribbon Generator for Visual Studio 2013

Note that it this one will only work for VS 2013. Download contains RibbonGenerator binaries and source.
http://sdrv.ms/1ewICJN

Register the Ribbon Generator (Custom Tool)

– Create a .reg file and import it. This one will only work with VS 2013 and a x64 Windows.

Windows Registry Editor Version 5.00</pre>
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\CLSID\{B64582D9-A489-42F4-BA55-BB6039D82916}]
@="RibbonGenerator"
"InprocServer32"="C:\\WINDOWS\\system32\\mscoree.dll"
"Class"="RibbonGenerator.CustomTool"
"Assembly"="RibbonGenerator, Version=1.0.1.0, Culture=neutral, PublicKeyToken=3cf107c5d7e68b1c"
"ThreadingModel"="Both"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\Generators\{164B10B9-B200-11D0-8C61-00A0C91E29D5}\RibbonGenerator]
@="Ribbon Generator"
"CLSID"="{B64582D9-A489-42F4-BA55-BB6039D82916}"
"GeneratesDesignTimeSource"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\Generators\{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}\RibbonGenerator]
@="Ribbon Generator"
"CLSID"="{B64582D9-A489-42F4-BA55-BB6039D82916}"
"GeneratesDesignTimeSource"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\12.0\Generators\{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}\RibbonGenerator]
@="Ribbon Generator"
"CLSID"="{B64582D9-A489-42F4-BA55-BB6039D82916}"
"GeneratesDesignTimeSource"=dword:00000001
<pre>

– Open Cmd as Administrator

– Use the correct version of gacutil.

“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe” -i “C:\…\RibbonGenerator.dll”

Check RibbonGenerator Registration

Check that Ribbon Generator is working correctly.

– Open the Ribbon-cs.sln solution

– Right-click on RibbonMarkup.xml and click Run Custom Tool

Bild 167

The following screenshot means, you have done a mistake in the previous steps.

Bild 166

Update the template.bat

No error occurred, but still not work? Check that all the tools are on your hard disc. Check all pathes to be  correct …

C:\Users\<user>\AppData\Local\RibbonGenerator\Template.bat”


"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\UICC.exe" "{XmlFilename}" "{BmlFilename}" /res:"{RcFilename}"
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\rc.exe" /v "{RcFilename}"
cmd /c "("%VS120COMNTOOLS%..\..\VC\bin\vcvars32.bat") && ("%VS120COMNTOOLS%..\..\VC\bin\link.exe" /VERBOSE /NOENTRY /DLL /OUT:"{DllFilename}" "{ResFilename}")"

Other Ribbon Posts

Quickstart Tutorial: Windows Ribbon for WinForms
RibbonGenerator Details: Windows Ribbon for WinForms
RibbonGenerator for Visual Studio 2010 Express Editions: Windows Ribbon for WinForms

RibbonGenerator for Visual Studio 2010 Express Editions: Windows Ribbon for WinForms

Yes, RibbonGenerator is also working with Express Editions of Visual Studio 2010, but in version 2.6 of the Ribbon library you need some extra effort to bring the tool up to work.

Requirements:

  • Windows 7 SDK
  • Visual  C++ 2010 Express
  • Visual C# or Basic 2010 Express

Note: You must have Visual C++ 2010 Express Edition installed because it contains the link.exe file that is need to generate .ribbon files.

Manual Registration of Custom Tool

Because the RibbonGenerator setup is not included in compiled format and because the Express Editions does not support setup projects, it is necessary to register the custom tool manually.

  1. Start the “.\RibbonLib_v2.6\RibbonGenerator\RibbonGenerator.sln” solution and ignore all errors
  2. Compile it
  3. Install the RibbonGenerator.dll into the GAC using gacutil.exe in Visual Studio 2010 Command Prompt (Run as Administrator)
    gacutil – i RibbonGenerator.dll
  4. Register the custom tool in Express Edition of Visual Studio 2010. The simplest way is to modify the existing .reg in the RibbonGenerator source folder. Choose the x64 reg file if you have a 64bit operating system. .\RibbonGenerator\RegisterCustomTool_VS2010.reg
    .\RibbonGenerator\RegisterCustomTool_VS2010_x64.reg
    Let take a look into the second one
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\CLSID\{B64582D9-A489-42F4-BA55-BB6039D82916}]
@="RibbonGenerator"
"InprocServer32"="C:\\WINDOWS\\system32\\mscoree.dll"
"Class"="RibbonGenerator.CustomTool"
"Assembly"="RibbonGenerator, Version=1.0.1.0, Culture=neutral, PublicKeyToken=3cf107c5d7e68b1c"
"ThreadingModel"="Both"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Generators\{164B10B9-B200-11D0-8C61-00A0C91E29D5}\RibbonGenerator]
@="Ribbon Generator"
"CLSID"="{B64582D9-A489-42F4-BA55-BB6039D82916}"
"GeneratesDesignTimeSource"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Generators\{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}\RibbonGenerator]
@="Ribbon Generator"
"CLSID"="{B64582D9-A489-42F4-BA55-BB6039D82916}"
"GeneratesDesignTimeSource"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Generators\{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}\RibbonGenerator]
@="Ribbon Generator"
"CLSID"="{B64582D9-A489-42F4-BA55-BB6039D82916}"
"GeneratesDesignTimeSource"=dword:00000001

All we have to do now, is to place the correct keys for Express Editions

For Visual Studio 2010 (64bit Operating System)

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0

For Visual C# 2010 Express (64bit Operating System)

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCSExpress\10.0

For Visual Basic 2010 Express (64bit Operating System)

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VBExpress\10.0

Other Ribbon Posts

Quickstart Tutorial: Windows Ribbon for WinForms
RibbonGenerator Details: Windows Ribbon for WinForms
Windows Ribbon for WinForms in Visual Studio 2013

RibbonGenerator Details: Windows Ribbon for WinForms

Let take a look into the details of RibbonGenerator of Windows Ribbon for WinForms

What is RibbonGenerator doing?

It generates .ribbon files that contains the definition of the commands and controls and can be used to display a Ribbon control on a Windows Form.

What type of application is RibbonGenerator?

There two applications available that can be used to generate .ribbon files.

  • A custom tool that can be used directly inside Visual Studio and
  • A console application that can be used from command line

Both application are having the same functionality.

How is RibbonGenerator generating .ribbon files?

Because there is no API available, the tool is “just” executing a .bat file. It is a custom .bat file. The content is created by the tool. After the first invocation the “template.bat” is placed in the following folder:
C:\Users\<username>\AppData\Local\RibbonGenerator
You can customize it. When you delete it, it will be recreated after the next invocation of RibbonGenerator.

What does this .bat file doing?

Let take a look into the template.bat file.

"C:\Program Files\Microsoft SDKs\Windows\v7.0\bin\UICC.exe" "{XmlFilename}" "{BmlFilename}" /res:"{RcFilename}"
"C:\Program Files\Microsoft SDKs\Windows\v7.0\bin\rc.exe" /v "{RcFilename}"
cmd /c "("%VS100COMNTOOLS%..\..\VC\bin\vcvars32.bat") && ("%VS100COMNTOOLS%..\..\VC\bin\link.exe" /VERBOSE /NOENTRY /DLL /OUT:"{DllFilename}" "{ResFilename}")"
  1. UICC.exe (available in Windows 7 SDK) is executed to generate a resource definition script file of the Ribbon XAML
  2. rc.exe (available in Windows 7 SDK) is executed to generate a .res file – a windows resource file
  3. link.exe (available in Visual Studio 2010 or Visual C++ 2010 Express)) is executed to generate an unmanaged .dll file. This file is the .ribbon file that can be used by Ribbon control!

The placeholder in there beginning with an “{” are all replaced by the tool. All files that are created will be deleted at the end of the generation process. Only the .ribbon file ({ResFilename} will not be deleted.

Questions:

Is is possible to use Windows 8 SDK?

Yes, the Windows 8 SDK contains UICC.exe and RC.exe, but the template.bat file must be modified to point to the files. You will find the tools by default in the following directory:

C:\Program Files\Windows Kits\8.0\bin\x86

You can download the Windows 8 SDK from there…

http://msdn.microsoft.com/en-us/windows/hardware/hh852363.aspx

 

Quickstart Tutorial: Windows Ribbon for WinForms

Here I will show you how you can start using the Windows Ribbon from CodePlex.

Prepare your developer machine
Installation of Windows 7 SDK is required to create and modify the ribbon on a developer machine.

1. Download latest version of RibbonLib from CodePlex

You can find the library here: http://windowsribbon.codeplex.com/

2. Build the RibbonGenerator setup and install it.

Start the Visual Studio 2010 Solution of RibbonGenerator, set the build configuration to Release and build it twice!
After the second build it will compile without errors! This is an official Visual Studio 2010 bug and we have to live with it.

.\RibbonLib_v2.6\RibbonGenerator\RibbonGenerator.sln

Now you can install the new setup file that you will find here…

.\RibbonLib_v2.6\RibbonGenerator\RibbonGenerator.Setup\Release\RibbonGenerator.Setup.msi

3. Compile a Ribbon.dll

To get a compiled version of Ribbon.dll start the sample solution and build it using Visual Studio

.\RibbonLib_v2.6\Ribbon-cs.sln

4. Create a new Windows Forms application containing the Ribbon Control.

Add the Ribbon to your Toolbox doing a right-click on Toolbox / Choose Items
.\RibbonLib_v2.6\Ribbon\bin\Release\Ribbon.dll

Drag/Drop the Ribbon to your form

For your body you can add a Panel control and set the DockStyle property to Fill

Add a new Xml file to your Project and rename to Ribbon.xml

Add the following content to the file.

<?xml version='1.0' encoding='utf-8'?>
<Application xmlns='http://schemas.microsoft.com/windows/2009/Ribbon'>
	<Application.Commands>
	</Application.Commands>

	<Application.Views>

		<Ribbon>
		</Ribbon>
	</Application.Views>
</Application>

Set the CustomTool of the Ribbon.xml in the File Properties to RibbonGenerator to generate a .ribbon file.

Now you need to specify the .ribbon file in the Ribbon control properties on your form. The name must be the full name including the namespace.

That’s all. So have a lot of fun playing with the samples included in the download package too.

Other Ribbon Posts

RibbonGenerator Details: Windows Ribbon for WinForms
RibbonGenerator for Visual Studio 2010 Express Editions: Windows Ribbon for WinForms
Windows Ribbon for WinForms in Visual Studio 2013
This guidance was written for Visual Studio 2010. If you want to use Visual Studio 2012 you should also read the posts from above.