?
=?ISO-8859-2?Q?=A3ukasz?=
Hi,
I'm writing application which is drawing an icon. Then it's displayed in
tray by NotifyIcon. And there is a problem, because sometimes an
exception is thrown:
Type: System.Runtime.InteropServices.ExternalException
Message:
A generic error occurred in GDI+.
Source:
System.Drawing
StackTrace:
at System.Drawing.Bitmap.GetHicon()
TargetSite:
IntPtr GetHicon()
Does enybody knows what's going on with this exception???
Code:
Bitmap bmp = new Bitmap(16, 16);
Graphics gr = Graphics.FromImage(bmp);
gr.Clear(Color.Transparent);
gr.FillRectangle(Brushes.White, 1, 2, 13, 12);
gr.DrawRectangle(Pens.Gray, 0, 1, 14, 13);
gr.DrawString(number.ToString("00"), this.Font, Brushes.Black, .0f, 1.0f);
gr.Dispose();
notifyIcon.Icon = (Icon)Icon.FromHandle(bmp.GetHicon()).Clone();
notifyIcon.Visible = true;
£ukasz
I'm writing application which is drawing an icon. Then it's displayed in
tray by NotifyIcon. And there is a problem, because sometimes an
exception is thrown:
Type: System.Runtime.InteropServices.ExternalException
Message:
A generic error occurred in GDI+.
Source:
System.Drawing
StackTrace:
at System.Drawing.Bitmap.GetHicon()
TargetSite:
IntPtr GetHicon()
Does enybody knows what's going on with this exception???
Code:
Bitmap bmp = new Bitmap(16, 16);
Graphics gr = Graphics.FromImage(bmp);
gr.Clear(Color.Transparent);
gr.FillRectangle(Brushes.White, 1, 2, 13, 12);
gr.DrawRectangle(Pens.Gray, 0, 1, 14, 13);
gr.DrawString(number.ToString("00"), this.Font, Brushes.Black, .0f, 1.0f);
gr.Dispose();
notifyIcon.Icon = (Icon)Icon.FromHandle(bmp.GetHicon()).Clone();
notifyIcon.Visible = true;
£ukasz