Why do my icons randomly appear?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have an issue with images that appear and then seem to disappear depending
on the compile and exectution sequence I use. I haven't been able to narrow
down a repeateable sequnce. I suspect this is an initialization problem. I
wonder if anyone else knows how to fix this?

In my C# Form Load() method, I include the following (m_ToolBarImageList is
defined as a instance ImageList):

m_ToolBarImageList = new ImageList();
m_ToolBarImageList.ImageSize = new System.Drawing.Size(16, 16);
m_ToolBarImageList.TransparentColor = System.Drawing.Color.Transparent;

// Read images from a compiled resource
m_ToolBarImageList.Images.Add(Image.FromStream(Utilities.GetIconAsStream("Resources.icons.Aladdin_16x16.ico")));
m_ToolBarImageList.Images.Add(Image.FromStream(Utilities.GetIconAsStream("Resources.icons.FAB_16x16.ico")));

// Assign the image list to the toolbar
this.toolBar1.ImageList = m_ToolBarImageList;

this.toolBar1.Buttons[0].ImageIndex=0;
this.toolBar1.Buttons[1].ImageIndex=1;
 
Hello,

I assume you haven't marked your Main Method with
the right Appartment Model...

[STAThread]
public static void Main()

You have to mark it as single threaded.

HTH, Günther
 
Back
Top