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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Create a button that can be dragged and dropped??

Create a button that can be dragged and dropped??

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 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.
  • H Offline
    H Offline
    Hachaso
    wrote on last edited by
    #1

    Hi! How can I create a button on a Dialog that can be dragged and dropped? Thanks!

    T M 2 Replies Last reply
    0
    • H Hachaso

      Hi! How can I create a button on a Dialog that can be dragged and dropped? Thanks!

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      maybe by overriding WM_LBUTTONDOWN


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      1 Reply Last reply
      0
      • H Hachaso

        Hi! How can I create a button on a Dialog that can be dragged and dropped? Thanks!

        M Offline
        M Offline
        MailtoGops
        wrote on last edited by
        #3

        Hi, There is no direct method available for this.. You can follow the following steps. Assumption: Parent window and children to be draged already created You need to handle three mouse events.. WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP 1. In the WM_LBUTTONDOWN message, call the SetCapture function with the control ID 2. In the WM_MOUSEMOVE message, call the GetCapture method and check the returned Window handle againt the your window child control window handle. If both are same, call SetWindowPos() to set the control new position. 3. In the WM_LBUTTONUP, check for the GetCapture() returned window handle is equal to your window control handle. If it is call ReleaseCapture() method, and once again place the window control by using SetWindowPos(). One more thing you have to take care is , when user clicks the button, he can drag that button out of parent window. To avoid such a situation, call the ClipCursor() function with the parent window rectangle size values...Then don't forgot to free the cursor. That you can do it by ClipCursor(NULL).. Enjoy programming... " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

        H 1 Reply Last reply
        0
        • M MailtoGops

          Hi, There is no direct method available for this.. You can follow the following steps. Assumption: Parent window and children to be draged already created You need to handle three mouse events.. WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP 1. In the WM_LBUTTONDOWN message, call the SetCapture function with the control ID 2. In the WM_MOUSEMOVE message, call the GetCapture method and check the returned Window handle againt the your window child control window handle. If both are same, call SetWindowPos() to set the control new position. 3. In the WM_LBUTTONUP, check for the GetCapture() returned window handle is equal to your window control handle. If it is call ReleaseCapture() method, and once again place the window control by using SetWindowPos(). One more thing you have to take care is , when user clicks the button, he can drag that button out of parent window. To avoid such a situation, call the ClipCursor() function with the parent window rectangle size values...Then don't forgot to free the cursor. That you can do it by ClipCursor(NULL).. Enjoy programming... " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

          H Offline
          H Offline
          Hachaso
          wrote on last edited by
          #4

          Thanks! But can this be done using OLE drag and drop? If so, how do I do it? Can't seem to find any good information of how to drag Controls. Thanks!

          M 1 Reply Last reply
          0
          • H Hachaso

            Thanks! But can this be done using OLE drag and drop? If so, how do I do it? Can't seem to find any good information of how to drag Controls. Thanks!

            M Offline
            M Offline
            MailtoGops
            wrote on last edited by
            #5

            No. You cannot.. " Action without vision is only passing time, Vision without action is merely day dreaming, But vision with action can change the world " - Words from Nelson Mandela Thanks & Regards, Gopalakrishnan

            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