开发者

Use System Images in C#

开发者 https://www.devze.com 2023-02-20 01:01 出处:网络
I am creating a custom messagebox. How ca开发者_如何转开发n I use system pictures such as Error, Information, Warning and etc, which I see in windows MessageBox? I want to access them directly!Take a

I am creating a custom messagebox. How ca开发者_如何转开发n I use system pictures such as Error, Information, Warning and etc, which I see in windows MessageBox? I want to access them directly!


Take a look at System.Drawing.SystemIcons. You should find them there.

Then set your PictureBox (assuming Winforms here) like this:

PictureBox1.Image = System.Drawing.SystemIcons.Warning.ToBitmap();


You need to look into the messagebox class a little further. You can specify a "MessageBoxIcon" when calling the method.

There are some good examples on how to acheive this here: http://www.dotnetperls.com/messagebox-show


You can draw the System icons in your custom MessageBox by handling the Paint event, e.g.

void MyMessageBox_Paint(object sender, PaintEventArgs e)
{
    e.Graphics.DrawIcon(SystemIcons.Warning, 16, 16);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消