Surface.LockRectangle(Type,Rectangle,LockFlags,Int32,Int32[]) Method (Microsoft.DirectX.Direct3D)

Locks a rectangle on a surface.


Visual Basic Public Function LockRectangle( _
    ByVal typeLock As TypeLeave Site, _
    ByVal rect As RectangleLeave Site, _
    ByVal flags As LockFlags, _
    ByRef pitch As Integer, _
    ByVal ranks() As Integer _
) As ArrayLeave Site
C# public ArrayLeave Site LockRectangle(
    TypeLeave Site typeLock,
    RectangleLeave Site rect,
    LockFlags flags,
    out int pitch,
    int[] ranks
C++ public:
ArrayLeave SiteLockRectangle(
    TypeLeave SitetypeLock,
    RectangleLeave Site rect,
    LockFlags flags,
    [Out] intpitch,
    array<int>^ ranks
JScript public function LockRectangle(
    typeLock : TypeLeave Site,
    rect : RectangleLeave Site,
    flags : LockFlags,
    pitch : int,
    ranks : int[]
) : ArrayLeave Site;


typeLock System.Type
A TypeLeave Site object that specifies the type of array to create.
rect System.Drawing.Rectangle
A RectangleLeave Site object that represents the rectangle to lock.
flags Microsoft.DirectX.Direct3D.LockFlags
A LockFlags object that specifies the type of lock to apply.
pitch System.Int32
Integer that represents the returned pitch value of the locked region.
ranks System.Int32[]
Array of one to three Int32Leave Site values that indicate the dimensions of the returned array. The maximum number of ranks allowed is three.

Return Value

An ArrayLeave Site that describes the locked region.


If LockFlags.DoNotWait is specified and the driver cannot lock the surface immediately, Surface.LockRectangle throws WasStillDrawingException so that an application can use the CPU cycles while waiting for the driver to lock the surface.

The only lockable format for a depth-stencil surface is Format.D16Lockable.

For performance reasons, dirty regions are recorded only for level zero of a texture. Dirty regions are automatically recorded when Surface.LockRectangle is called without LockFlags.NoDirtyUpdate or LockFlags.ReadOnly. For more information, see Device.UpdateTexture.

A multisample back buffer cannot be locked.



The method call is invalid. For example, a method's parameter might contain an invalid value.

See Also