Error404 Error404 - 3 months ago 10
Vb.net Question

Get the Default WIndows System Icons for minimize, maximize and close

I want to create an borderless WinForm which has a custom header with the Default System Icons for:


  • Minimization

  • Maximization

  • Closing



Is there any Way i can achieve this in C# or VB?

Answer

Not sure what your exact goal is, but gernerally, for 'custom'-designs using C# I would prefer WPF (Windows Presentation Foundation) instead of Windows Forms...

I guess it´s possible in Windows Forms too, maybe if you remove the borders as wanted and create 3 Buttons, using the common Windows-symbols as their background? But I´m not sure if it´s working ;)

EDIT :

using a controls 'paint'-event, you should be able to reach your goal:

private void button_Paint(object sender, PaintEventArgs e)
{
    if (VisualStyleRenderer.IsElementDefined(VisualStyleElement.Window.CloseButton.Normal))
    {
        VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Window.CloseButton.Normal);
        Rectangle rectangle1 = new Rectangle(button.Location.X, button.Location.Y, button.Width, button.Height);
        renderer.DrawBackground(e.Graphics, rectangle1);
    }
}

this is checking if you are able to use the styles, and then draw the selected VisualStyleElement (eg. CloseButton, MinButton, etc.) to the button/control´s position.

See VisualStylesElement-CloseButton and Control.Paint-Event for more information.

works fine for me, hope it´s what you´ve been looking for...

Comments