Working with Windows 7, .NET 4.0开发者_如何转开发 and C#. I've been spending a considerable amount of time working with the VisualStyleRenderer and the various elements that are available by default with the end goal of being able to manually draw the 'ThumbnalToolbarButton' on any surface I'd like.
For those of you unfamiliar with that UI component, an example can be viewed here:
The ThmubnailToolbarButton in this image are the two directional buttons; left, right, with the right button with hoverstate.
When working with the Taskbar preview/thumbnail/thumbnailtoolbar api either through interop or the Windows API Codepack, these elements are easily added. However, I've not been able to find a means to draw these elements manually. I'm not even sure it's doable, but would like to appeal to the community for the obvious that I'm missing, the undocumented, or an alternate method.
Thanks, Andrew
update
I've managed to track this down to the TaskbandExtendedUI class, 'LoneControl' element name within a given visual style, but I cannot seem to create an element for VisualStyleRenderer to use. It seems that the part count is only valid to 5, and the 'LoneControl' element name is at the sixth index under the TaskbandExtendedUI class.
update 2
Finally figured this bugger out. Here's the code to get the job done:
// class : TaskBandExtendedUI
// part : 1, name :Background
// part : 2, name :BackgroundShadow
// part : 3, name :ListItem
// part : 4, name :Title
// part : 5, name :Border
// part : 8, name :LoneControl
// part : 9, name :LeftControl
// part : 10, name :CenterControl
// part : 11, name :RightControl
// part : 12, name :CloseCaption
// part : 13, name :ScrollBar
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
VisualStyleElement element= VisualStyleElement.CreateElement("TaskbandExtendedUI", 8, 2);
VisualStyleRenderer renderer = new VisualStyleRenderer(element);
renderer.DrawBackground(e.Graphics, new Rectangle(100, 100, 100, 100));
}
精彩评论