Drag & Drop event - would this work

D

David Thielen

Hi;

Ok, there is no Drop event from Word. But would the following work:

1. They drag from a modeless window my Add-In has up.
2. When they drop my window gets the Form drop event asking me to render the
clipboard data.
3. I query Word to ask where the cursor is. Is there a way to do this and is
it accurate in this situation?
4. I then render the data in RTF format based on what I want inserted at
that spot.

Would this work?
 
P

Peter Huang [MSFT]

Hi

Yes, we can drag from a winform, but where do you drop it?
If you drop onto the winform, the winforms will get notified just as a
common winform dragdrop application,
but if you drop onto the winword, the winform's drop event will not fire.

Also word's OM did not expose the Cursor related interface for us to get
the location, we have to use the Cursor class of .NET framework or API, but
that will not associate with the position in the word window.

Hope this helps.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

Hi;

I know I don't get the drop event in Word. But won't I get a winform event
asking me to render the clipboard contents when the drop occurs? If so,
couldn't I use that to tell me the drop is occuring?

For the cursor location, does the Word OM provide a way where I can give it
a line, column and it will tell me where that is on the page? Or give it a
location on the page and it gives me the line & column? I was thinking that
embedded objects would need this information in order to draw themselves.

Or am I off-base on this?
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=,
For the cursor location, does the Word OM provide a way where I can give it
a line, column and it will tell me where that is on the page? Or give it a
location on the page and it gives me the line & column? I was thinking that
embedded objects would need this information in order to draw themselves.
If I'm not mistaken, doesn't the selection (IP) change when one drops on a
Word window? So just get the Selection object? And from that, if you need
more, there's the Information property with things like
RelativeHorizontalPosition and RelativeVerticalPosition.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
D

David Thielen

Hi;

Bummer - I tried this but the selection is not the drop point.

Any ideas on any other way to determine the drop point?
 
D

David Thielen

However, I can get the mouse position - is there a call in to Word where I
pass the coordinates on the screen and it gives me the location in the
document?
 
D

David Thielen

Another key question. Lets say I have 2 instances of Word open, and each have
there own "drag from" window because they will have different stuff in them.

How can I know which instance of Word the drop is occuring in. Because I
can't allow a drop from one into the other.

?????
 
P

Peter Huang [MSFT]

Hi

Based on my navigate through all the object property method, it seems that
word did not expose such feature for us to get the information.
I think word is an high encapsulated application, its main target is to
maintain the easy usage for the end-user, so it expose the high level com
interface for addin or vba coder to manipulate the necessary function we
expose. Too many deep low level customization may reduce the stability of
the winword application.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi

As I said before, word has its buildin mechanism to handle the drop event,
we will not be notified and can not customized it.
So if we drop on word window A, the word window A will handle the drop to
paste the correct content, it will not paste into the second word windows B.
Is this your concern?
If I have any misunderstanding, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=,
However, I can get the mouse position - is there a call in to Word where I
pass the coordinates on the screen and it gives me the location in the
document?
I'm fast running out of ideas, but...

If you can get the mouse position, can you force a mouse-click?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
D

David Thielen

Hi;

No my question was slightly different. Is there a way to know what Document
the paste will go in to? I have a bad feeling the answer is no - but the Word
application that will get the paste is in the call stack - is there some way
- maybe getting the window that has the focus, walk up the parent windows
till you get a window with class OpusApp, then look at the hwnd?

thanks - dave
 
D

David Thielen

Hi;

I agree 100% with keeping it high level - both to keep the API sane and to
keep Word stable.

Of course, when there isn't a high level API to do something, then it
becomes hack city to work around it - which is not good for anyone.

Could you please touch base with the Word team to 1) Ask them to add an
event for DocumentBeforeDrop(Document, RangeWhereDropWillHappen, DropObject)
and 2) Ask them if there is a safer way to get the drop location than Cindy's
idea?
 
D

David Thielen

Oh,

And a second event while the object is being dragged over word giving the
same 3 parameters and letting it return if it can drop at that location and
what cursor to show.
 
P

Peter Huang [MSFT]

Hi

As I said before, when drop occur, winword will take the responsibility to
handle the drop, and we have no chance to get notified, so we have no idea
which document is dropped on.

Also since the drop will change something in the document, I think you may
try to add event handler on these document's change event to see which one
has been changed.

BTW: Use Win32 API to customize Word is not supported, because we have no
offcial document and the detailed implement in winword is not public, we
can not guarantee it will keep workding. Because we may change certain
behavior in the later version.

Also thanks for your feedback about the DocumentBeforeDrop, I recommend
that in the mswish website, our specified team will evaluate the ideas and
may add in the later version.
http://register.microsoft.com/mswish/suggestion.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi

Sorry for that, I have reported the problem to our content team.

Now you may try the alternative approaches.

E-mail
To send comments or suggestions via e-mail, use the following Microsoft
Wish Program e-mail address:
(e-mail address removed)

FAX
To send comments or suggestions via FAX, use the following Microsoft FAX
number:
(425) 936-7329
Note: Address the FAX to the attention of the Microsoft Wish Program.

US Mail
To send comments or suggestions via US Mail, use the following Microsoft
mailing address:
Microsoft Corporation
Attn. Microsoft Wish Program
One Microsoft Way
Redmond, WA 98052-6399

Thanks!


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

rushikesh.joshi

Hi Friends,

This is my second post in past 5 days. And I belive that this right
ppls and place to ask my query....please some one try to help me.

I have created an add in C#, which is popup a form on excel.
Now my query is, i have a tree control which contain some data. now
when user drag any item to excel cell at that time i want information
about that cell...like cell location, WorkSheet name, cell
value...etc

At first it's seems easy...but it's not. I have tried by using invoke
methods of excel...but no luck no any idea which method i have to
invoke Is there any way from where i can findout/raise that dropor
dropleave method of excel Worksheet.

Your help is greatly appreciated.

Thanks,
Rushikesh Joshi
 

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

Top