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);
}
精彩评论