Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Graphics.DrawImageAbort Delegate

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

[Visual Basic]
<Serializable>
<ComVisible(False)>
Public Delegate Function Sub Graphics.DrawImageAbort( _
   ByVal callbackdata As IntPtr _
) As Boolean
[C#]
[Serializable]
[ComVisible(false)]
public delegate bool Graphics.DrawImageAbort(
   IntPtr callbackdata
);
[C++]
[Serializable]
[ComVisible(false)]
public __gc __delegate bool Graphics.DrawImageAbort(
   IntPtr callbackdata
);

[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [Visual Basic, C#, C++]

The declaration of your callback method must have the same parameters as the Graphics.DrawImageAbort delegate declaration.

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 IntPtr.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.

Remarks

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.

Example

[Visual Basic, C#] 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.

[Visual Basic, C#] A realistic implementation of this callback would involve the actual scrutiny of some criteria to cancel or continue the execution.

[Visual Basic] 
Private Function DrawImageCallback(callBackData As IntPtr) As Boolean
    ' Test for call that passes callBackData parameter.
    If callBackData.Equals(IntPtr.Zero) Then
        ' If no callBackData passed, abort DrawImage method.
        Return True
    Else
        ' If callBackData passed, continue DrawImage method.
        Return False
    End If
End Function 'DrawImageCallback
      
[C#] 
// 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;
   }
}
      

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Drawing

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Drawing (in System.Drawing.dll)

See Also

System.Drawing Namespace

Show:
© 2015 Microsoft