Help with SafeGDIHandle()

ogjogj Posts: 2
edited February 24, 2017 2:29PM in PInvoke.Net
Hello all,

I was looking at the example codes for the API calls to ImageList_DrawExhttp://www.pinvoke.net/default.aspx/comctl32.ImageList_DrawEx and ImageList_SetOverlay http://www.pinvoke.net/default.aspx/comctl32/ImageList_SetOverlayImage.html in comctl32.

The code examples make a reference to a SafeGDIHandle() class.

Does anyone know where I can find the code or an example for this class?

Thanks!

Comments

  • Here you are:
    using System;
    using System.Runtime.InteropServices;
    using System.Runtime.ConstrainedExecution;
    using System.Security.Permissions;
    using Microsoft.Win32.SafeHandles;
    ...
    [SecurityPermission(SecurityAction.Demand, UnmanagedCode = true)]
    class SafeGDIHandle : SafeHandleZeroOrMinusOneIsInvalid
    {
        internal SafeGDIHandle()
            : base(true)
        {
        }
    
        internal SafeGDIHandle(IntPtr existingHandle, bool ownsHandle)
            : base(ownsHandle)
        {
            SetHandle(existingHandle);
        }
    
        protected override bool ReleaseHandle()
        {
            return NativeMethods.DeleteObject(handle);
        }
    }
    
Sign In or Register to comment.