Magnum
Magnum

Reputation: 1595

Identifying controls in a Windows Form

Can anybody identify what type of Windows Form control(s) the Select signature to edit, Choose default signature, and Edit Signature are in the Microsoft Outlook insert signature modal? I cannot figure out if it's a super-shruken panel, or if it's some other control I'm not finding?

enter image description here

Upvotes: 0

Views: 440

Answers (2)

Tergiver
Tergiver

Reputation: 14517

They are not controls at all. Most of what you see on that dialog is what I call "pseudo controls", that is painted bits that look and operate as controls, but which do not have system windows. You can see this by using a Spy tool to find the (non-existent) system windows.

You can achieve this yourself with Graphics.DrawText and ControlPaint.DrawXXX, where XXX I'm not sure of. Maybe Border, or 3DBorder?

Here's a cheap and dirty example. I used the WinForms Label control because it was easy.

using System;
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

    public Form1()
    {
        ClientSize = new Size(400, 200);
        Controls.Add(new LineLabel { Text = "Edit signature", Location = new Point(10, 10), Anchor = AnchorStyles.Left | AnchorStyles.Right, Width = 380 });
    }
}

public class LineLabel : Label
{
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);

        SizeF textSize = e.Graphics.MeasureString(this.Text, this.Font);
        int leftWidth = (int)(textSize.Width + 2);
        Rectangle bounds = new Rectangle(leftWidth, Height / 2 - 4, Bounds.Width - leftWidth, 2);
        ControlPaint.DrawBorder(e.Graphics, bounds, Color.DarkGray, ButtonBorderStyle.Solid);
    }
}

Upvotes: 3

Wim Ombelets
Wim Ombelets

Reputation: 5265

They are GroupBoxes, albeit looking a little modified in terms of their borders. If you would like to customize your own, you could do that for a WinForms groupbox (to some extent) but it will prove a LOT easier to go with a WPF Groupbox and read up on styling in Styling a GroupBox.

A must-read is also MSDN - How To Define a GroupBox Template.

Upvotes: 1

Related Questions