Skip to content

[API Addition] Message.GetLParam<T>() #792

@hughbe

Description

@hughbe

We currently have

public class Message
{
        // ..
        public object GetLParam(Type cls) => Marshal.PtrToStructure(LParam, cls);
        // ..
}

However, this is implemented using Marshal.PtrToStructure which has been obsoleted. I propose adding a new API that uses the un-obsoleted marshal API:

public class Message
{
        // ..
        public T GetLParam<T>() => Marshal.PtrToStructure<T>(LParam);
        // ..
}

This would avoid the need for all the casting, e.g

NativeMethods.NMHDR nmhdr = (NativeMethods.NMHDR)m.GetLParam(typeof(NativeMethods.NMHDR));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions