An expert had previously helped me before on this site create a custom mouse icon when I am dragging an item from a textbox onto a panel. This was done using the control.givefeedback method like so:
private void listBox1_GiveFeedback(object sender, GiveFeedbackEventArgs e)
e.UseDefaultCursors = false;
Bitmap bmp = new Bitmap(252, 192);
Graphics g = Graphics.FromImage(bmp);
panel1.Cursor = new Cursor(bmp.GetHicon());
This essentially creates a black box that you can move around the panel until you let go of the mousebutton, where it then sticks in place. This was all working fine until I had reports of crashing. I did some memory tests and it appears the more I drag around the mouse when the custom cursor is created the more memory it consumes, until the app eventually runs out of memory. If the cursor has been created, but I do not move the mouse the memory still increases but not as fast as if I move it all over the screen. When I let go of the mouse button the memory stops increasing, but it never decreases. This leads me to believe I am creating an object somewhere repeatedly that is not being released, but for the life of me I cannot figure out where. Any ideas?