Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Hello at all,
I have a custom OnScroll event in my ListView.
For this event I use the GetScrollInfo method (user32.dll).
But, when I use rdp client for use my application on the cloud,
I receive this error: 1421 "ERROR CONTROL ID NOT FOUND".

This is the code:
C#
struct SCROLLINFO {
    public uint cbSize;    // set to sizeof (SCROLLINFO)
    public uint fMask;     // values to set or get
    public int nMin;       // minimum range value
    public int nMax;       // maximum range value
    public uint nPage;     // page size
    public int nPos;       // current position
    public int nTrackPos;  // current tracking position
}

C#
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetScrollInfo(IntPtr hwnd, int fnBar, ref SCROLLINFO lpsi);

C#
private ScrollEventType GestisciScroll(ScrollEventType TipoScrollPrefedinito) {
    SCROLLINFO _info = new SCROLLINFO();
    _info.fMask = (uint)SIF_ALL;
    ScrollEventType _typeScroll = TipoScrollPrefedinito;
    if (GetScrollInfo(this.Handle, SB_VERT, ref _info)) {
        if ((_info.nPos + _info.nPage) > _info.nMax)
            _typeScroll = ScrollEventType.Last;
        else if (_info.nPos == 0)
            _typeScroll = ScrollEventType.First;
    } else {
        System.Diagnostics.Trace.WriteLine(Marshal.GetLastWin32Error());      
        // ERROR 1421 HERE!
    }
    return _typeScroll;
}


Can you help me?
Thank you.
Posted
Updated 5-Jun-13 0:07am
v4
Comments
Sunasara Imdadhusen 5-Jun-13 8:56am    
Are you using any third party library?
Dario Michael 7-Jun-13 5:08am    
No. Is a normal ListView.
But I use this application in remote desktop.

1 solution

Hi,

I have this working, try it.

C#
private struct ScrollInfoStruct
        {
            public int cbSize;
            public int fMask;
            public int nMin;
            public int nMax;
            public in<b></b>t nPage;
            public int nPos;
            public int nTrackPos;
        }

[DllImport("user32.dll", SetLastError=true) ]
private static extern int GetScrollInfo(IntPtr hWnd, int n, ref ScrollInfoStruct lpScrollInfo );
 
Share this answer
 
Comments
Dario Michael 21-Nov-13 8:54am    
Hi,
I tried it and it works locally but In RDP doesn't work.
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900