Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Dragging a borderless Form....

Dragging a borderless Form....

Scheduled Pinned Locked Moved Managed C++/CLI
questiongraphics
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qwick Miller
    wrote on last edited by
    #1

    I have my Form borders set to "none", because I am using a bitmap for my background. How do I drag the Form so the user can move the Form?

    C 1 Reply Last reply
    0
    • Q Qwick Miller

      I have my Form borders set to "none", because I am using a bitmap for my background. How do I drag the Form so the user can move the Form?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      By catching a click and drag in whatever area works for you and setting your own window position based on the difference between the current mouse pos, and the mouse pos when you last checked. Christian Graus - Microsoft MVP - C++

      Q 1 Reply Last reply
      0
      • C Christian Graus

        By catching a click and drag in whatever area works for you and setting your own window position based on the difference between the current mouse pos, and the mouse pos when you last checked. Christian Graus - Microsoft MVP - C++

        Q Offline
        Q Offline
        Qwick Miller
        wrote on last edited by
        #3

        Would you show me some code examples?

        C 1 Reply Last reply
        0
        • Q Qwick Miller

          Would you show me some code examples?

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          POINT lastDrag OnMouseDown { lastDrag = CurrentMousePosition (should be a parameter passed in to the event handler, but not this name ) } OnMouseMove { POINT moved = lastDrag - CurrentMousePosition lastDrag = CurrentMousePosition ::SetWindowPos(NULL, currentX + moved.X, currentY + moved.Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER) } This is pseudocode. Christian Graus - Microsoft MVP - C++

          Q 1 Reply Last reply
          0
          • C Christian Graus

            POINT lastDrag OnMouseDown { lastDrag = CurrentMousePosition (should be a parameter passed in to the event handler, but not this name ) } OnMouseMove { POINT moved = lastDrag - CurrentMousePosition lastDrag = CurrentMousePosition ::SetWindowPos(NULL, currentX + moved.X, currentY + moved.Y, 0, 0, SWP_NOSIZE | SWP_NOZORDER) } This is pseudocode. Christian Graus - Microsoft MVP - C++

            Q Offline
            Q Offline
            Qwick Miller
            wrote on last edited by
            #5

            Here's the solution: http://www.codeproject.com/csharp/CustomForms.asp[^] Point mouse_offset; .._MouseDown(..., System::Windows::Forms::MouseEventArgs * e) { mouse_offset = Point(-e->get_X(), -e->get_Y()); } .._MouseMove(..., System::Windows::Forms::MouseEventArgs * e) { if (e->Button == MouseButtons::Left){ Point mousePos = this->get_MousePosition(); mousePos.Offset(mouse_offset.X, mouse_offset.Y); this->set_Location(mousePos); } }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups