Hi,
I have a form application that has a number of pictureboxes. As the program runs it changes the pictures in the boxes depending on buttons pressed on the form via a function 'updateGUI'.
The program runs for a limited period and eventually i get an error:
An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll
Additional information: Parameter is not valid.
when the updateGUI function is run. The error occurs on the line (underlined):
if ( MyImage5 != nullptr )
{
delete MyImage5;
}
picturebox_5->SizeMode = PictureBoxSizeMode::StretchImage;
[U]MyImage5 = gcnew Bitmap( <filetodisplay system string> ); [/U]
picturebox_5->Image = dynamic_cast<Image^>(MyImage5);
I have checked the program, which is far too large to post, and the only thing i can think of that is causing the error is recursivity.
Essentially, the program loads up the form but doesn't close it down until the user exits the program. While the form is on screen, functions in the main.cpp file are called many times over, however, the program is designed so that no function runs more than once without user input (via buttons) in between each call.
Would the problem be solved with some sort of periodic memory dump regarding the pictureboxes?
Any help would be greatly appreciated.