我们正在使用图标的ToBitmap()方法将SystemIcons转换为位图。 但它产生了异常“参数无效”
下面是我使用的代码..
SETP-1
foreach (var data in procwprintcjheck)
{
if (data.Select == true)
{
try
{
if (this.Email(data.Mail_ToAddress))
{
}
else
{
CustomMessageBox.Show(CultureManager.GetMessageString("CW_EmailIDs_not_valid"), CultureManager.GetMessageString("AP_Email_Invalid"), CustomMessageBox.CYButtons.OK, CustomMessageBox.CYIcon.Information);
this.Close();
}
}
catch (Exception ex)
{
CusException cex = new CusException(ex);
cex.Show(MessageBoxIcon.Error);
}
}
}
Setp -2 功能调用显示方法
CustomMessageBox.Show(CultureManager.GetMessageString("CW_EmailIDs_not_valid"), CultureManager.GetMessageString("AP_Email_Invalid"), CustomMessageBox.CYButtons.OK, CustomMessageBox.CYIcon.Information);
第3步 在IconStatments函数下方显示的metod内部正在调用
static private Icon IconStatements(CYIcon MIcon)
{
Icon icon = SystemIcons.Error;
if (MIcon == CYIcon.Error)
{
MessageBeep(30);
//frmIcon = new Icon(SystemIcons.Error, 40, 40);
icon = SystemIcons.Error;
}
if (MIcon == CYIcon.Information)
{
MessageBeep(0);
//frmIcon = new Icon(SystemIcons.Information, 40, 40);
icon = SystemIcons.Information;
}
if (MIcon == CYIcon.Question)
{
MessageBeep(0);
//frmIcon = new Icon(SystemIcons.Question, 40, 40);
icon = SystemIcons.Question;
}
if (MIcon == CYIcon.Warning)
{
MessageBeep(30);
// replace warning to Exclamation
//frmIcon = Icon.FromHandle(largeIcon[217]);
// frmIcon = new Icon(SystemIcons.Exclamation, 40, 40);
icon = SystemIcons.Warning;
}
if (MIcon == CYIcon.Exclamation)
{
MessageBeep(0);
//frmIcon = new Icon(SystemIcons.Exclamation, 40, 40);
icon = SystemIcons.Exclamation;
}
if (MIcon == CYIcon.Asterisk)
{
MessageBeep(30);
//frmIcon = new Icon(SystemIcons.Asterisk, 40, 40);
icon = SystemIcons.Asterisk;
}
return icon;
}
来自另一个功能块的函数调用。
图片imageIcon =新位图(IconStatements(MIcon).ToBitmap(),38,38);
pIcon.Image = imageIcon;
上面突出显示的行给了我错误。我被困在这里 任何人都可以建议我该怎么做才能解决这个错误。