Programmatically initiate a drag and drop operation

  • Thread starter Thread starter benkial
  • Start date Start date
B

benkial

I am writing a small GUI tool in C#, and I want to experiment some
fancy trick as follows: when the user click on a "OK" button, the code
will initiate a "Drag and Drop" operation in the GUI itself to itself
(i.e. drag some fake object and drop to the tool itself).

I am new to .Net programming, but from my reading can I achieve this
using SendMessage() or PostMessage() to force a "Drag and Drop"
operation?

Thanks in advance,

Ben
 
Hello (e-mail address removed),

Look there http://www.syncfusion.com/faq/windowsforms/default.aspx search
by "drag" keyword and you will find a lot of samples
I am writing a small GUI tool in C#, and I want to experiment some
fancy trick as follows: when the user click on a "OK" button, the code
will initiate a "Drag and Drop" operation in the GUI itself to itself
(i.e. drag some fake object and drop to the tool itself).

I am new to .Net programming, but from my reading can I achieve this
using SendMessage() or PostMessage() to force a "Drag and Drop"
operation?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Michael,

I did a search in that site, but none of the links answers my question.
They are all "general" drag and drop coding that requires a user to
manually "Drag" and "Drop". My question is how to do the drag and drop
operation without the user even knows about it.


Ben
 
If the ok button is clicked and that makes the drag and drop occur, all you
need is a method to do the drag and drop operation and have that called when
ok is clicked?

i presume that does not solve your problem because i doubt you would be
stuck if it did. Could you explain why that would not work?
 
Do You want to animate some object then do the Drag Drop operation.
It might not have to be a true dragdrop, you can animate and at the end of
the animation do some operation.
Right?

B
 
What I want is a way to drag a fake object and invoke the "Drop"
operation of any Windows (e.g. Word) that the user specified. It does
not need any animation effect. Is there any way I can simply "Post"
some message using "PostMessage()" to the target window and achieve the
same effect of a manual "Drop" operation?
 
you never answered my original question to you.

But if you dont want an animation effect then there will be no drag effect.
Your not being very clear at all.

Is it that you want the end result of a drag and drop operation.....which if
you do there is no need to mention drag and drop at all hence the confusion.
i really dont get what you are trying to achieve here at all.

But to invoke anything message wise use delegates and events. Then on the
'ok button click' fire that event.

I have just a had a thought, i believe in the designer in vis studio you can
set a 'on drop' event handler so that in the event of an on drag and drop
that event handler is fired and you can then handle the response. If this is
what you are trying to do and that is why then this is the wrong approach
and my original question regarding just use the ok buttons to do your needs
still stands.

Either way i am confused by your requirement but good luck.
 
Sorry that I didn't make it clear the first time. What I want to do is
to experiement with a way to invoke the "Drop" handler of any given
Windows as if I manually drop some objecct into that Window. The test
GUI I start with is just to experiement to see if I can
programmatically simulate a user's mouse "drag" from a fake object and
"drop" to the target Window.
 
Oh in that case you only need to attach your method to the onDrop event of
the form. I dont know what event is called but find out what the event is
for drop and do the

event += DropEvent(MyMethod);

This is very very pseudo code but look up attaching events and it will do
what you want. Then on dropping something it will fire the event which in
turn will fire your method allowing you to do what you like.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top