For a small program that I am developing, I decided it's best to implement a Quick Access Toolbar (like those that come with Ribbon controls (office 2007, 2010?)). Now my problem is that I cannot find any free Ribbon control for winforms from which I could extract the toolbar.
I have a pseudo-QAC at the moment but there is a rendering issue with the standard toolbar.
So can anyone show me a good implementation for this control? It must be OS-independent. (No DWM-only non-client are removing.)
For others, this is my result:
In a new form, I add the following code:
protected override CreateParams CreateParams
{
get
{
var cp = base.CreateParams; // Retrieve the normal parameters.
cp.Style = 0x40000000 | 0x4000000; // WS_CHILD | WS_CLIPSIBLINGS
cp.ExStyle &= 0x00080000; // WS_EX_LAYERED
cp.Parent = GetDesktopWindow(); // Make "GetDesktopWindow()" from your own namespace.
return cp;
}
}
And then place a toolbox with a style provided by Cody Gray, and I always move this form with it's owner and now I have a quick access toolbar! :D
From what I gather in reading the comments, you are looking for a simple toolbar control that provides a quick way for the user to perform common tasks/operations. However, unlike the Quick Access Toolbar included in a Microsoft Office-style Ribbon, you don't want a solution that requires drawing in the non-client area because this solution is not portable. Drawing in the non-client area requires rolling out completely custom window chrome, which isn't going to work seamlessly across all versions of Windows (because of DWM and a host of other reasons).
I suggested using the standard ToolStrip
control provided in the Framework, but you expressed concern that it draws a white line underneath it and said that when you try to hide this white line by placing it inside a panel, the highlight border (which you want) gets covered as well.
Therefore, I propose a couple of possible solutions:
1. The ToolStrip
's bottom white border only gets drawn when its RenderMode
property is set to "System". You can set it to "Professional" instead and banish the white line forever, while retaining the darkened hover border effect.
2. If you don't like the "Professional" rendering style and want to stick with "System", you can simply inherit off of the existing ToolStripSystemRenderer
and stop it from drawing the bottom white border:
public class CorrectedToolStripRenderer : ToolStripSystemRenderer
{
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
//do nothing here
}
}
And then simply set the ToolStrip
control to use your custom renderer, like so:
myToolStrip.Renderer = new CorrectedToolStripRenderer();
3. You can implement a completely custom renderer for the ToolStrip
, derived directly from the base ToolStripRenderer
class, and define for yourself exactly how you want it to look.
For example, because I hate controls that don't look like standard Windows UI elements, I have a custom renderer that I use to ensure menus and toolbars in all of my WinForms applications are painted just like those in the OS. ("System" doesn't get it anywhere close to right in Vista/7.) Mine is a heavily-modified version of this sample.
Others (here's looking at you, Office team) absolutely love a custom UI, and this way allows you to really go all out and match the appearance of your application. For example, here are custom renderers that look like Visual Studio 2010 or Office 2007 to get you started. A Google search will turn up tons more.