Help with SafeGDIHandle()

Announcements and discussion for PInvoke

Help with SafeGDIHandle()

Postby ogj » Wed Feb 15, 2017 3:04 pm

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!
ogj
 
Posts: 1
Joined: Wed Feb 15, 2017 2:53 pm

Re: Help with SafeGDIHandle()

Postby KarlssonPaTakel » Fri Feb 24, 2017 7:29 pm

Here you are:
Code: Select all
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);
    }
}
KarlssonPaTakel
 
Posts: 2
Joined: Fri Feb 24, 2017 7:19 pm


Return to PInvoke.Net

Who is online

Users browsing this forum: No registered users and 1 guest