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#
  4. drag and drop issue...

drag and drop issue...

Scheduled Pinned Locked Moved C#
helpbeta-testingquestioncode-review
6 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.
  • S Offline
    S Offline
    Super Lloyd
    wrote on last edited by
    #1

    If I use software like OpenOffice and try to drag text I could notice that 1. when I drag inside the document I'm moving the text 2. when I drag outside the document I'm copying the text Yet it all looks like one smooth operation. With correct cursor feedback (the little + marker next to the icon). My problem is, once I call DoDragDrop() it's blocking, I have no other opportunities to change the AllowedEffect to only Copy if I drag over, say, an other control. And QueryContinueDrag: 1. don't allow me to change the efect 2. don't inform me about the current drop target How could I do that? (i.e. how could I modify the allowed effect depending on the target (i.e. wether it's me or not))

    W 1 Reply Last reply
    0
    • S Super Lloyd

      If I use software like OpenOffice and try to drag text I could notice that 1. when I drag inside the document I'm moving the text 2. when I drag outside the document I'm copying the text Yet it all looks like one smooth operation. With correct cursor feedback (the little + marker next to the icon). My problem is, once I call DoDragDrop() it's blocking, I have no other opportunities to change the AllowedEffect to only Copy if I drag over, say, an other control. And QueryContinueDrag: 1. don't allow me to change the efect 2. don't inform me about the current drop target How could I do that? (i.e. how could I modify the allowed effect depending on the target (i.e. wether it's me or not))

      W Offline
      W Offline
      Weckmann
      wrote on last edited by
      #2

      Almost every component has a few drag/drop events which can be used to switch the allowed effects. In your case you should use the DragLeave event to change the effect when the mouse leaves your form for example. As long as the mouse hovers somewhere in your application you can do whatever you want with the DragEnter and DragOver events of each component that is under the cursor. -------------------- Bertram Weckmann www.svizzer.com --------------------

      S 1 Reply Last reply
      0
      • W Weckmann

        Almost every component has a few drag/drop events which can be used to switch the allowed effects. In your case you should use the DragLeave event to change the effect when the mouse leaves your form for example. As long as the mouse hovers somewhere in your application you can do whatever you want with the DragEnter and DragOver events of each component that is under the cursor. -------------------- Bertram Weckmann www.svizzer.com --------------------

        S Offline
        S Offline
        Super Lloyd
        wrote on last edited by
        #3

        You are wrong or I missed something. DragEnter is only called on the target of drag and drop (not the source of the data) and the allowed effect can't be changed (as it is set by the source of the drag not the target), as the target can just the selected effect. I need to change the allowed effect when I drag in other control/component, including other application. the dragenter is not the appropriaote event as it is something I need to do in the source of the dragging, not the destination

        W 1 Reply Last reply
        0
        • S Super Lloyd

          You are wrong or I missed something. DragEnter is only called on the target of drag and drop (not the source of the data) and the allowed effect can't be changed (as it is set by the source of the drag not the target), as the target can just the selected effect. I need to change the allowed effect when I drag in other control/component, including other application. the dragenter is not the appropriaote event as it is something I need to do in the source of the dragging, not the destination

          W Offline
          W Offline
          Weckmann
          wrote on last edited by
          #4

          Well, when you start the dragdrop operation you can set the effects which are allowed. After that point it is up to the component over which the cursor is dragged which of these effects are shown. So if it is a component which does not belong to your application, you can only give it a set of effects and which of those will be chosen is up to the application. I made a very very simple example: http://g10.wilde-edv.de/PublicStuff/DragDropTest.zip There you can drag the Button1 to the text field or to the button2. I set the allowed effects to copy and move. The button2 only accepts move and the text field only copy. So the icon is changed to the appropriate effect as soon as you drag over the control. When you drag outside the form the other applications will pick either the copy or the move effect, or none if they do not accept the data. Hope that helps.

          -------------------- Bertram Weckmann www.svizzer.com --------------------

          S 1 Reply Last reply
          0
          • W Weckmann

            Well, when you start the dragdrop operation you can set the effects which are allowed. After that point it is up to the component over which the cursor is dragged which of these effects are shown. So if it is a component which does not belong to your application, you can only give it a set of effects and which of those will be chosen is up to the application. I made a very very simple example: http://g10.wilde-edv.de/PublicStuff/DragDropTest.zip There you can drag the Button1 to the text field or to the button2. I set the allowed effects to copy and move. The button2 only accepts move and the text field only copy. So the icon is changed to the appropriate effect as soon as you drag over the control. When you drag outside the form the other applications will pick either the copy or the move effect, or none if they do not accept the data. Hope that helps.

            -------------------- Bertram Weckmann www.svizzer.com --------------------

            S Offline
            S Offline
            Super Lloyd
            wrote on last edited by
            #5

            Sorry I didn't explain my self vey well... I would like to do something like that in the source: // == pseuo code if(source == this) AllowedEffect = All else AllowedEffect = Copy just like word. when you drag text inside a word document it move it, if you drag to an other document it's a copy. your sample don't address this issue at all. In fact it seems you haven't realised yet that it is seemingly impossible with the public API of the control... Thanks for trying to answer anyway ;)

            W 1 Reply Last reply
            0
            • S Super Lloyd

              Sorry I didn't explain my self vey well... I would like to do something like that in the source: // == pseuo code if(source == this) AllowedEffect = All else AllowedEffect = Copy just like word. when you drag text inside a word document it move it, if you drag to an other document it's a copy. your sample don't address this issue at all. In fact it seems you haven't realised yet that it is seemingly impossible with the public API of the control... Thanks for trying to answer anyway ;)

              W Offline
              W Offline
              Weckmann
              wrote on last edited by
              #6

              OK now Im trying to understand what you originally wanted. ;-) The AllowedEffect has to be set at the beginning of the drag/drop operation. Afterwards it is read-only. But nevertheless you can imitate the behaviour of Word: Start the drag/drop operation with the allowed effects Move AND Copy. Just fill the data in, but dont remove it yet from the source. Then just set all target controls to allow ONLY Move and design the DragDrop event handlers in a way that the data is actually moved, so remove it from the source. Now if the user drags it out of your application almost every other application will pick the copy effect because they dont have any drag/drop handler for a move operation from anything coming from somewhere else. And since you left the original data where it was at the beginning, everything done by other applications will be a copy operation. And there is your Word behaviour. Inside your application you have a Move, outside you have a Copy. Got you this time? ;-)

              -------------------- Bertram Weckmann www.svizzer.com --------------------

              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