Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 697841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:12:34+00:00 2026-05-14T03:12:34+00:00

I use MouseMove event to move objects(say labels). simple principle(schematic): OnMouseMove(e MouseEventArgs) if e.Button

  • 0

I use MouseMove event to move objects(say labels).

simple principle(schematic):

OnMouseMove(e MouseEventArgs)
    if e.Button == Left
        deltaX = e.X - lastX
        foreach label in labels
            label.Location.X += deltaX
        lastX = e.X

Once the labels number increase, I start to see the labels traces along the moving trajectory.
I have something like I I I II III II I I III II, but want to have something like I I I I as traces. I’d like to know when the mouse “starts” and “stops to move” something like this.

I move labels along a horizontal axe. MouseDown(set LastX) and go on. Nobody knows when stops, only mouse move sensibility. Surely I can use MouseUp to know when the movement ends, but however if user maintains the button down and stop moving I want to reflect the latest label position.

Is there a way to prevent this kind of traces?

tried

label.Visible = false
label.Location.X += deltaX
label.Visible = true

does not help.

parent.SuspendLayout and ResumeLayout does not help a lot, because I need doing this at every mouse movement, so any effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:12:35+00:00Added an answer on May 14, 2026 at 3:12 am

    Edit: I’ve just noticed your edit about when the mouse stops. You could use a timer to help you. Have one set to the interval you want to update the positions on and auto reset when it elapses. Start it on mouse down and stop it on mouse up. When the timer elapses, update the locations of the labels.

    —Original answer for context:—

    Yes, you can suspend drawing on the parent control, move the labels, and then resume drawing and refresh.

    From this SO question:

    [DllImport("user32.dll")]
    public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
    
    private const int WM_SETREDRAW = 11; 
    
    public static void SuspendDrawing(Control parent)
    {
        SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
    }
    
    public static void ResumeDrawing(Control parent)
    {
        SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
        parent.Refresh();
    }
    

    Example Usage:

    private void OnMouseMove(MouseEventArgs e)
    {
        int deltaX = e.X - lastX;
        // Suspend drawing here
    
        foreach (Label label in labels)
        {
            label.Location.X += deltaX;
        }
    
        lastX = e.X;
        // Resume drawing here
    }
    

    Edit: If you only want to show the change in position if the difference is greater than n pixels, then you should use the Pythagorean Theorem to calculate the distance between the old position and the new position and only move it if the difference is greater than n. When the mouse button comes up, move the labels to the location they are supposed to be according to the mouse.

    Pseudo-code:

    difference = Math.Sqrt(x * x, y * y);
    
    if (difference > n)  // n is whatever number you want
    {
         // move the labels
         // set the old position to the new position
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a card playing game. I the use mousemove event to
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
I'm trying to draw a single line using OnMouseMove() event. My Problem is that
My question is about memory use and objects in actionscript 2. If I have
Let's say I have a cubic Bezier path as follows (formatted for use with
jQuery is firing on every mousemove event for me. How do I get it
I use jQuery.click to handle the mouse click event on Raphael graph, meanwhile, I
I have a list of objects that I use to add objects into a
How to move an image with mouse? onmousedown and onmousemove are the events to
Use case: A does something on his box and gots stuck. He asks B

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.