Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Graphics.DrawImageAbort Delegate

Provides a callback method for deciding when the DrawImage method should prematurely cancel execution and stop drawing an image.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public delegate bool DrawImageAbort (
	IntPtr callbackdata
)
/** @delegate */
public delegate boolean DrawImageAbort (
	IntPtr callbackdata
)
Not applicable.

Parameters

callbackdata

Internal pointer that specifies data for the callback method. This parameter is not passed by all DrawImage overloads. You can test for its absence by checking for the value Zero.

Return Value

This method returns true if it decides that the DrawImage method should prematurely stop execution. Otherwise it returns false to indicate that the DrawImage method should continue execution.

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 Graphics.DrawImageAbort 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 Graphics.DrawImageAbort delegate declaration.

This example is a simplistic implementation of the Graphics.DrawImageAbort 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.

// Define DrawImageAbort callback method.
 private bool DrawImageCallback(IntPtr callbackdata)
 {
    // Test for call that passes callBackData parameter.
    if(callbackdata==IntPtr.Zero)
    {
       // If no callbackdata passed, cancel DrawImage method.
       return true;
    }
    else
    {
       // If callbackdata passed, continue DrawImage method.
       return false;
    }
 }

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.