نمایش نتایج 1 تا 1 از 1

نام تاپیک: اسکرول فرم در صفحه تاچ

  1. #1
    منتظر تایید آدرس ایمیل
    تاریخ عضویت
    خرداد 1391
    پست
    337

    Post اسکرول فرم در صفحه تاچ

    سلام. این رو برا کسی گذاشتم که تاپیکش حذف شد. )mohammad sadeghi‏ (به علت نام نامناسب

    یک

    internal class MouseFilter : IMessageFilter
    {
    private const int WM_LBUTTONDOWN = 0x0201;
    private const int WM_LBUTTONUP = 0x0202;
    private const int WM_MOUSEMOVE = 0x0200;

    /// <summary>
    /// Filtert eine Meldung, bevor sie gesendet wird.
    /// </summary>
    /// <param name="m">Die zu sendende Meldung. Diese Meldung kann nicht geändert werden.</param>
    /// <returns>
    /// true, um die Meldung zu filtern und das Senden zu verhindern. false, um das Senden der Meldung bis zum nächsten Filter oder Steuerelement zu ermöglichen.
    /// </returns>
    public bool PreFilterMessage(ref Message m)
    {
    Point mousePosition = Control.MousePosition;
    var args = new MouseFilterEventArgs(MouseButtons.Left, 0, mousePosition.X, mousePosition.Y, 0);

    switch (m.Msg)
    {
    case WM_MOUSEMOVE:
    if (MouseFilterMove != null)
    {
    MouseFilterMove(Control.FromHandle(m.HWnd), args);
    }
    break;

    case WM_LBUTTONDOWN:
    if (MouseFilterDown != null)
    {
    MouseFilterDown(Control.FromHandle(m.HWnd), args);
    }
    break;

    case WM_LBUTTONUP:
    if (MouseFilterUp != null)
    {
    MouseFilterUp(Control.FromHandle(m.HWnd), args);
    }
    break;
    }

    // Always allow message to continue to the next filter control
    return args.Handled;
    }

    /// <summary>
    /// Occurs when [mouse filter up].
    /// </summary>
    public event MouseFilterEventHandler MouseFilterUp;

    /// <summary>
    /// Occurs when [mouse filter down].
    /// </summary>
    public event MouseFilterEventHandler MouseFilterDown;

    /// <summary>
    /// Occurs when [mouse filter move].
    /// </summary>
    public event MouseFilterMoveEventHandler MouseFilterMove;
    }

    internal delegate void MouseFilterEventHandler(object sender, MouseFilterEventArgs args);

    internal delegate void MouseFilterMoveEventHandler(object sender, MouseFilterEventArgs args);

    internal class MouseFilterEventArgs
    {
    /// <summary>
    /// Initializes a new instance of the <see cref="MouseFilterEventArgs" /> class.
    /// </summary>
    /// <param name="mouseButton">The mouse button.</param>
    /// <param name="clicks">The clicks.</param>
    /// <param name="x">The x.</param>
    /// <param name="y">The y.</param>
    /// <param name="delta">The delta.</param>
    public MouseFilterEventArgs(MouseButtons mouseButton, int clicks, int x, int y, int delta)
    {
    Button = mouseButton;
    Clicks = clicks;
    X = x;
    Y = y;
    Delta = delta;
    Handled = false;
    }

    /// <summary>
    /// Gets or sets the button.
    /// </summary>
    /// <value>
    /// The button.
    /// </value>
    public MouseButtons Button { get; set; }

    /// <summary>
    /// Gets or sets a value indicating whether this <see cref="MouseFilterEventArgs" /> is handled.
    /// </summary>
    /// <value>
    /// <c>true</c> if handled; otherwise, <c>false</c>.
    /// </value>
    public bool Handled { get; set; }

    /// <summary>
    /// Gets or sets the X.
    /// </summary>
    /// <value>
    /// The X.
    /// </value>
    public int X { get; set; }

    /// <summary>
    /// Gets or sets the Y.
    /// </summary>
    /// <value>
    /// The Y.
    /// </value>
    public int Y { get; set; }

    /// <summary>
    /// Gets or sets the clicks.
    /// </summary>
    /// <value>
    /// The clicks.
    /// </value>
    public int Clicks { get; set; }

    /// <summary>
    /// Gets or sets the delta.
    /// </summary>
    /// <value>
    /// The delta.
    /// </value>
    public int Delta { get; set; }
    }


    دو


    static class Program
    {
    public static MouseFilter mouseFilter = new MouseFilter();

    /// <summary>
    /// Der Haupteinstiegspunkt für die Anwendung.
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.AddMessageFilter(mouseFilter);
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(fals e);
    Application.Run(new MainForm());
    }
    }


    سه

    public partial class MainForm : Form
    {
    private bool _doTouchScroll;
    private Point _mouseStartPoint = Point.Empty;
    private Point _yourScrollablePanelStartPoint = Point.Empty;

    /// <summary>
    /// Initializes a new instance of the <see cref="MainForm" /> class.
    /// </summary>
    public MainForm()
    {
    InitializeComponent();

    Program.mouseFilter.MouseFilterDown += mouseFilter_MouseFilterDown;
    Program.mouseFilter.MouseFilterMove += mouseFilter_MouseFilterMove;
    Program.mouseFilter.MouseFilterUp += mouseFilter_MouseFilterUp;
    }

    /// <summary>
    /// Handles the MouseFilterDown event of the mudmFilter control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">
    /// The <see cref="MouseFilterEventArgs" /> instance containing the event data.
    /// </param>
    private void mouseFilter_MouseFilterDown(object sender, MouseFilterEventArgs e)
    {
    if (!_doTouchScroll && e.Button == MouseButtons.Left)
    {
    _mouseStartPoint = new Point(e.X, e.Y);
    _yourScrollablePanelStartPoint = new Point(-yourScrollablePanel.AutoScrollPosition.X,
    -yourScrollablePanel.AutoScrollPosition.Y);
    }
    }

    /// <summary>
    /// Handles the MouseFilterMove event of the mudmFilter control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">
    /// The <see cref="MouseFilterEventArgs" /> instance containing the event data.
    /// </param>
    private void mouseFilter_MouseFilterMove(object sender, MouseFilterEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    {
    if (!_mouseStartPoint.Equals(Point.Empty))
    {
    int dx = (e.X - _mouseStartPoint.X);
    int dy = (e.Y - _mouseStartPoint.Y);

    if (_doTouchScroll)
    {
    yourScrollablePanel.AutoScrollPosition = new Point(_yourScrollablePanelStartPoint.X - dx,
    _yourScrollablePanelStartPoint.Y - dy);
    }
    else if (Math.Abs(dx) > 10 || Math.Abs(dy) > 10)
    {
    _doTouchScroll = true;
    }
    }
    }
    }

    /// <summary>
    /// Handles the MouseFilterUp event of the mudmFilter control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">
    /// The <see cref="MouseFilterEventArgs" /> instance containing the event data.
    /// </param>
    private void mouseFilter_MouseFilterUp(object sender, MouseFilterEventArgs e)
    {
    if (e.Button == MouseButtons.Left)
    {
    if (_doTouchScroll && !yourScrollablePanel.AutoScrollPosition.Equals(_yo urScrollablePanelStartPoint) &&
    !_yourScrollablePanelStartPoint.Equals(Point.Empty ))
    {
    // dont fire Click-Event
    e.Handled = true;
    }
    _doTouchScroll = false;
    _mouseStartPoint = Point.Empty;
    _yourScrollablePanelStartPoint = Point.Empty;
    }
    }
    }

    آخرین ویرایش به وسیله kamiloted : سه شنبه 23 شهریور 1395 در 13:00 عصر

تاپیک های مشابه

  1. مکان نمایش فرم در صفحه به صورت دستی
    نوشته شده توسط دختر باران در بخش C#‎‎
    پاسخ: 4
    آخرین پست: شنبه 19 دی 1388, 10:29 صبح
  2. حرکت فرم در صفحه
    نوشته شده توسط rezapassword در بخش VB.NET
    پاسخ: 18
    آخرین پست: شنبه 28 دی 1387, 11:51 صبح
  3. سوال: چگونه مكان فرم در صفحه مانيتور را ميشود كنترل كرد؟
    نوشته شده توسط sib_data در بخش Access
    پاسخ: 1
    آخرین پست: یک شنبه 28 مهر 1387, 09:24 صبح
  4. پاسخ: 9
    آخرین پست: پنج شنبه 29 آذر 1386, 09:49 صبح
  5. پست کردن دیتا با بیش از یک فرم در صفحه وب
    نوشته شده توسط rezadavodi در بخش ASP.NET Web Forms
    پاسخ: 0
    آخرین پست: یک شنبه 04 شهریور 1386, 15:44 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •