Provides a callback method for deciding when the DrawImage method should prematurely cancel execution and stop drawing an image.
Assembly: System.Drawing (in System.Drawing.dll)
This method is used in conjunction with the DrawImage method of the Graphics class. Certain overloads of the DrawImage method call an application-defined callback method of this type to find out if the overloads should stop or continue execution.
During execution, the relevant DrawImage overloads frequently call this callback method to find out if they should stop drawing the specified image or if they should continue drawing the image. The callback method can determine whether to continue or not based on a chosen algorithm included in it, optionally using the data passed to it by the callbackdata parameter. For example, an algorithm might determine if the image has scrolled off the screen and signal a cancellation to the DrawImage method to stop drawing.
A user declaration of this event-handling method must have the same parameters as the delegate declaration.
This example is a simplistic implementation of the delegate. It merely checks to see if the DrawImage method has passed it data using the callbackdata parameter. (Some DrawImage overloads have only a DrawImageAbort parameter and pass no data; some overloads have both DrawImageAbort and callbackdata parameters and can pass data.) If no data was passed, it returns true to signal to the calling DrawImage method that it should cancel the drawing. If data was passed, it returns false to signal that drawing should continue.
A realistic implementation of this callback would involve the actual scrutiny of some criteria to cancel or continue the execution.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)