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

  • Home
  • SEARCH
  • 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 4576008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:08:43+00:00 2026-05-21T20:08:43+00:00

That’s the code i have to drag my window. It kinda works! Kind of…

  • 0

That’s the code i have to drag my window. It kinda works! Kind of…

Private Point startPoint;

private void Window_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{

    startPoint = e.GetPosition(null);
}
private void Window_MouseMove(object sender, MouseEventArgs e)
{
    if (e.LeftButton == MouseButtonState.Pressed)
    {
        Point relative = e.GetPosition(null);
        Point AbsolutePos = new Point(relative.X + this.Left, relative.Y + this.Top);
        this.Top = AbsolutePos.Y - startPoint.Y;
        this.Left = AbsolutePos.X - startPoint.X;
    }
}

The problem is if i move the mouse too fast, it will go out of the window and stop raising the movemouse event. Second, the dragging window is not smooth at all which makes me believed i’m not doing it the right way. Third, I’ve tried this on Window_MouseLeftButtonDown which would fire the event just once per mouse click.
I’m a beginner, a simple example free of Dropping and Data transferring would be appreciated by me and many others beginners like me. thanks in advance to Stack OverFlow users willing to help.

  • 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-21T20:08:43+00:00Added an answer on May 21, 2026 at 8:08 pm

    Losing the mouse is a result of failing to capture the mouse. The standard procedure is:

    • capture the mouse in the mouse down event and record the mouse position
    • handle the mouse motion in the mouse move event if the button is depressed
    • release the mouse capture in the mouse up event and perform any final processing

    As far as the performance, you are going about it the right way. The speed is limited by the repainting of the window itself and any windows the window passes over and how fast your computer is and what else is going on on computer while you are dragging it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That title is presumably awfully worded. I have some PostgreSQL tables. There is a
That's pretty much what I am trying to accomplish. To have each image appear
That's how cell selection looks in MS Excel: Is it possible to have the
That sounds complicated, doesn't it... actually it's quite easy: I have a multi-language app
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
That's what I want to know. If I have to encrypt the cookie value
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's basically it. I have a demo up here . I have been going
That is, on disk, if I have an array of std::complex , is it

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.