Enable a thread to process this function.
/// <Summary>
/// Flash the image in the specified image control
/// </Summary>
/// <Param name = "pic"> image control to be flashed </param>
Public static void flashimage (Object picbox)
{
Picturebox PIC = picbox as picturebox;
If (PIC = NULL)
Thread. currentthread. Abort ();
System. Windows. Forms. Control. checkforillegalcrossthreadcils = false;
// Cross-thread call. NET Framework 2.0 may cause this problem. You can run the specified delegate asynchronously on the thread where the basic handle of the control is created.
Bitmap BMP = new Bitmap (23, 23); // The size depends on the situation and does not affect other parts of the interface.
Graphics gph;
// Create a new graphics object from the specified image object
Color colortouming = color. fromargb (0,240,240,240); // transparent color
Gph = graphics. fromimage (BMP );
Bitmap mybit = new Bitmap (PIC. Image); // the picture of the picturebox control to be flashed
While (true)
{
Gph. Clear (colortouming );
Gph. drawimage (mybit, 0, 1, 20, 20 );
PIC. Image = BMP; // receives the message, and the picture beats
Thread. Sleep (300 );
Gph. Clear (colortouming );
Gph. drawimage (mybit, 1, 0, 23, 23 );
PIC. Image = BMP; // receives the message, and the picture beats
Thread. Sleep (300 );
Gph. Clear (colortouming );
Gph. drawimage (mybit, 1, 1, 20, 20 );
PIC. Image = BMP; // receives the message, and the picture beats
Thread. Sleep (300 );
Gph. Clear (colortouming );
Gph. drawimage (mybit, 1, 0, 23, 23 );
PIC. Image = BMP; // receives the message, and the picture beats
Thread. Sleep (300 );
}
}