Scrolling & end scroll events

Completed

Comments

4 comments

  • Dapfor Team

    Thank you for this question. Our grid is based on standard System.Windows.Forms control and as other controls it receives WM_ messages. Actual version of the grid doesn’t provide convenient interface with scroll information. Nevertheless you can create a class that derives from .Net Grid and you can retrieve needed scroll information from WinProc virtual method. Below you can see an example:


    class CustomGrid : Grid
    {
    public const int WM_VSCROLL = 0x0115;
    public const int SB_ENDSCROLL = 8;

    protected override void WndProc(ref Message m)
    {
    bool endScroll = false;
    switch (m.Msg)
    {
    case WM_VSCROLL:
    int sbCode = (m.WParam.ToInt32()) & 0xFFFF;
    switch (sbCode)
    {
    case SB_ENDSCROLL:
    endScroll = true;
    break;
    }

    break;
    }

    base.WndProc(ref m);
    }
    }



    In the next version of .NetGrid we will add nested events for vertical and horizontal scrolling. By the way do you know that there are methods Row.EnsureVisible and Cell.EnsureVisible() that scroll rows and columns to ensure visible required elements?
    Best regards,
    The Dapfor Team

    0
    Comment actions Permalink
  • Dapfor Team

    Hi,

    We have added Grid.Scroll event.

    Best regards,

    The Dapfor Team

    0
    Comment actions Permalink
  • Lim Hong Heng

    following is my doing, but i hope Dapfor team would make it up. Because using winproc in 64 bit machine isn't support at all. I have to set my app target platform to x86 oni insteal of all/any platform.

     

    using

     

    System;

    using

     

    System.Collections.Generic;

    using

     

    System.Text;

    using

     

    Dapfor.Net.Ui;

    using

     

    System.Windows.Forms;


    namespace

     

    TCProPlus

    {

       

    public class DaphorCustomGrid : Grid

        {

           

    public delegate void DelegateEndScroll();

           

    public event DelegateEndScroll EventEndScroll;

           

    public delegate void DelegateEndScroll2(bool dragging);

           

    public event DelegateEndScroll2 EventMouseDragging;

     

           

    public const int WM_HSCROLL = 0x114;

           

    public const int WM_VSCROLL = 0x0115;

           

    public const int WM_MOUSEWHEEL = 0x20A;

           

    public const int MK_CONTROL = 0x8;

           

    public const int MK_LBUTTON = 0x1;

           

    public const int MK_RBUTTON = 0x2;

           

    public const int MK_MBUTTON = 0x10;

           

    public const int MK_SHIFT = 0x4;

           

    public event MouseEventHandler mwMouseWheel;

           

    public const int SB_LINEUP = 0;

           

    public const int SB_LINEDOWN = 1;

           

    public const int SB_PAGEUP = 2;

           

    public const int SB_PAGEDOWN = 3;

           

    public const int SB_THUMBPOSITION = 4;

           

    public const int SB_THUMBTRACK = 5;

           

    public const int SB_TOP = 6;

           

    public const int SB_BOTTOM = 7;

           

    public const int SB_ENDSCROLL = 8;

           

    protected override void WndProc(ref Message m)

            {

               

    int xpos = m.LParam.ToInt32() & 65535;

               

    int ypos = m.LParam.ToInt32() / 65536;

               

    int MouseKeys = m.WParam.ToInt32() & 65535;

               

    int Rotation = m.WParam.ToInt32() / 65536;

               

    int delta = Rotation / 120;

               

    MouseButtons mb = new MouseButtons();

     

               

    bool endScroll = false;

               

    bool mouseClickHoldScrolling = false;

               

    switch (m.Msg)

                {

                   

    case WM_MOUSEWHEEL:

                       

    //Console.WriteLine("wheel");

                        OnMwMouseWheel(

    new MouseEventArgs(mb, 0, xpos, ypos, delta));

                       

    break;

                   

    case WM_VSCROLL:

                       

    int sbCode = (m.WParam.ToInt32()) & 0xFFFF;

                       

    switch (sbCode)

                        {

                           

    case SB_ENDSCROLL:

                                endScroll =

    true;

                               

    break;

                           

    case SB_LINEDOWN:

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_LINEUP:

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_PAGEDOWN:

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_PAGEUP:

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_THUMBTRACK:

                                mouseClickHoldScrolling =

    true;

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_TOP:

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_BOTTOM:

                               

    //Console.WriteLine();

                               

    break;

                           

    case SB_THUMBPOSITION:

                               

    //Console.WriteLine();

                               

    break;

                        }

                       

    break;

                }

               

    if (EventEndScroll != null)

                {

                   

    if (endScroll)

                    {

                        EventEndScroll();

                    }

                }

               

               

    if (EventMouseDragging != null)

                {

                    

    if (mouseClickHoldScrolling)

                    {

                        EventMouseDragging(

    true);

                    }

                   

    else

                    {

                        EventMouseDragging(

    false);

                    }

                }

            

               

    base.WndProc(ref m);

            }

           

    protected virtual void OnMwMouseWheel(MouseEventArgs e)

            {

               

    if (mwMouseWheel == null) return;

                mwMouseWheel(

    this, e);

            }

        }

    }

    0
    Comment actions Permalink
  • Dapfor Team
    Hi, we will add a support for end scroll event in the next version of the grid. Best regards, The Dapfor Team
    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk