How to use SetWindowLong in C#?

13,219

this should fix it

SetWindowLong ( c, (int)WindowLongFlags.GWL_STYLE,
    (uint) WindowStyles.WS_OVERLAPPED);
Share:
13,219
Joan Venge
Author by

Joan Venge

Professional hitman.

Updated on June 04, 2022

Comments

  • Joan Venge
    Joan Venge almost 2 years

    I use this function:

    [DllImport ( "user32.dll" )]
    static extern int SetWindowLong ( IntPtr hWnd, int nIndex, uint dwNewLong );
    

    and pass values from these:

    http://pinvoke.net/default.aspx/Constants/Window%20styles.html

    enum WindowLongFlags : int
    {
        GWL_EXSTYLE = -20,
        GWLP_HINSTANCE = -6,
        GWLP_HWNDPARENT = -8,
        GWL_ID = -12,
        GWL_STYLE = -16,
        GWL_USERDATA = -21,
        GWL_WNDPROC = -4,
        DWLP_USER = 0x8,
        DWLP_MSGRESULT = 0x0,
        DWLP_DLGPROC = 0x4
    }
    

    So when I call it as:

    SetWindowLong ( c, WindowLongFlags.GWL_STYLE, WindowStyles.WS_OVERLAPPED );
    

    I get these errors:

    Argument 2: cannot convert from 'timoti.WindowLongFlags' to 'int'

    Argument 3: cannot convert from 'timoti.WindowStyles' to 'uint'

    Is the pinvoke signature wrong as I have seen different ones online or am I missing something else?

  • Parimal Raj
    Parimal Raj almost 10 years
    @BenVoigt - yes! my bad !