handeling mouse events from within my addIn

T

Tamir

Hi all,
I have an addIn which I wrote for ms-word and i wish to handle mouse events
in my addin.
In my addin i use a class handler for each component that I wish to sink.
but here i dont know what to sink, I dont have (dont know) the GUID DIID__...
 
C

Cindy Meister

Hi Tamir

The Word object model exposes no mouse events. The closest you could manage
would be to use the Windows API, but I understand it's a real PAIN, if it
works at all.
 
T

Tamir

Hi Cindy Meister,
Maybe you will have an idea, ...
Basically I wish to add tips to some words in the document.
I want these tips to be shown when the mouse is placed on a word.
Further, I would like to add an item to the right-click menu of the mouse
(and sink it).
Is it possible to do without getting into troubles??? :)
 
C

Cindy Meister

Hi Tamir

for (1), the only thing Word provides are Comments. You can "Add" a Comment
for a RANGE object. You'll probably also want to turn off "balloons" display
if this is Word 2002 or later. In order to see this in the UI (and record a
macro in order to get the basic syntax), comments are inserted over
Insert/References/Comments. To turn off the "balloons", Tools/Options/Track
Changes

(2) The right-click menus are part of the CommandBars collection
(msoBarPopup type). No problem removing/adding CommandBar buttons to those.
As always, when working with Word's CommandBars, you want to consciously set
the CustomizationContext and, if the changes aren't for the single documents,
you want to be sure to return these CommandBars to their original state when
your Addin is finished.

The shortcut menus in Word can be accessed through Tools/Customize/Toolbars.
You'll get a toolbar with three entries, under these all the different
commandbars are listed. Depending on the context in which the mouse/cursor
finds itself, a different shortcut menu is shown, so it's possible you may
have to change more than one menu. To access a menu via the object model,
then:
CommandBars("NameAsYouSeeInTheList")

If you prefer to roll your own, rather than modify the built-in ones, you
need to sink the WindowBeforeRightClick event. That provides an argument to
cancel the default action, and you can display your own "Popup" commandbar,
instead.
 
T

Tamir

Hi Cindy Meister,
can you give me more details on how to add the comment.
Im writing in c++ and I use late-binding with functions such as
GetProperty(...) PutProperty(...) and CallMethod(...). I tried to add a
comment but did not succeeded.
I have:
hr=GetProperty(vtRange->pdispVal, L"Comments", &vtComents) ;//=S_OK
vtParam.vt=VT_BSTR;
vtParam.bstrVal=scrTip.AllocSysString();
hr=CallMethod(vtComents.pdispVal, L"Add", &vtComment, 1, &vtParam);//="Type
mismatch"
[vtX are VARIANT variables.]
I hope you can help me more.... any help is good.
 
C

Cindy Meister

Hi Tamir

I'm afraid I'm way out of my depth with C++ - no idea how the code for this
should look. From what I can see, you have the correct method and two
parameters (Range and Text), but beyond that...
--
-- Cindy


Tamir said:
Hi Cindy Meister,
can you give me more details on how to add the comment.
Im writing in c++ and I use late-binding with functions such as
GetProperty(...) PutProperty(...) and CallMethod(...). I tried to add a
comment but did not succeeded.
I have:
hr=GetProperty(vtRange->pdispVal, L"Comments", &vtComents) ;//=S_OK
vtParam.vt=VT_BSTR;
vtParam.bstrVal=scrTip.AllocSysString();
hr=CallMethod(vtComents.pdispVal, L"Add", &vtComment, 1, &vtParam);//="Type
mismatch"
[vtX are VARIANT variables.]
I hope you can help me more.... any help is good.
---
Thanks in advance,
Tamir.


Cindy Meister said:
Hi Tamir

for (1), the only thing Word provides are Comments. You can "Add" a Comment
for a RANGE object. You'll probably also want to turn off "balloons" display
if this is Word 2002 or later. In order to see this in the UI (and record a
macro in order to get the basic syntax), comments are inserted over
Insert/References/Comments. To turn off the "balloons", Tools/Options/Track
Changes

(2) The right-click menus are part of the CommandBars collection
(msoBarPopup type). No problem removing/adding CommandBar buttons to those.
As always, when working with Word's CommandBars, you want to consciously set
the CustomizationContext and, if the changes aren't for the single documents,
you want to be sure to return these CommandBars to their original state when
your Addin is finished.

The shortcut menus in Word can be accessed through Tools/Customize/Toolbars.
You'll get a toolbar with three entries, under these all the different
commandbars are listed. Depending on the context in which the mouse/cursor
finds itself, a different shortcut menu is shown, so it's possible you may
have to change more than one menu. To access a menu via the object model,
then:
CommandBars("NameAsYouSeeInTheList")

If you prefer to roll your own, rather than modify the built-in ones, you
need to sink the WindowBeforeRightClick event. That provides an argument to
cancel the default action, and you can display your own "Popup" commandbar,
instead.
 
T

Tamir

Thanks anyway.
Tamir.

Cindy Meister said:
Hi Tamir

I'm afraid I'm way out of my depth with C++ - no idea how the code for this
should look. From what I can see, you have the correct method and two
parameters (Range and Text), but beyond that...
--
-- Cindy


Tamir said:
Hi Cindy Meister,
can you give me more details on how to add the comment.
Im writing in c++ and I use late-binding with functions such as
GetProperty(...) PutProperty(...) and CallMethod(...). I tried to add a
comment but did not succeeded.
I have:
hr=GetProperty(vtRange->pdispVal, L"Comments", &vtComents) ;//=S_OK
vtParam.vt=VT_BSTR;
vtParam.bstrVal=scrTip.AllocSysString();
hr=CallMethod(vtComents.pdispVal, L"Add", &vtComment, 1, &vtParam);//="Type
mismatch"
[vtX are VARIANT variables.]
I hope you can help me more.... any help is good.
---
Thanks in advance,
Tamir.


Cindy Meister said:
Hi Tamir

for (1), the only thing Word provides are Comments. You can "Add" a Comment
for a RANGE object. You'll probably also want to turn off "balloons" display
if this is Word 2002 or later. In order to see this in the UI (and record a
macro in order to get the basic syntax), comments are inserted over
Insert/References/Comments. To turn off the "balloons", Tools/Options/Track
Changes

(2) The right-click menus are part of the CommandBars collection
(msoBarPopup type). No problem removing/adding CommandBar buttons to those.
As always, when working with Word's CommandBars, you want to consciously set
the CustomizationContext and, if the changes aren't for the single documents,
you want to be sure to return these CommandBars to their original state when
your Addin is finished.

The shortcut menus in Word can be accessed through Tools/Customize/Toolbars.
You'll get a toolbar with three entries, under these all the different
commandbars are listed. Depending on the context in which the mouse/cursor
finds itself, a different shortcut menu is shown, so it's possible you may
have to change more than one menu. To access a menu via the object model,
then:
CommandBars("NameAsYouSeeInTheList")

If you prefer to roll your own, rather than modify the built-in ones, you
need to sink the WindowBeforeRightClick event. That provides an argument to
cancel the default action, and you can display your own "Popup" commandbar,
instead.
--
-- Cindy


:

Hi Cindy Meister,
Maybe you will have an idea, ...
Basically I wish to add tips to some words in the document.
I want these tips to be shown when the mouse is placed on a word.
Further, I would like to add an item to the right-click menu of the mouse
(and sink it).
Is it possible to do without getting into troubles??? :)

:

Hi Tamir

The Word object model exposes no mouse events. The closest you could manage
would be to use the Windows API, but I understand it's a real PAIN, if it
works at all.
--
-- Cindy


:

Hi all,
I have an addIn which I wrote for ms-word and i wish to handle mouse events
in my addin.
In my addin i use a class handler for each component that I wish to sink.
but here i dont know what to sink, I dont have (dont know) the GUID DIID__...
----
can someone help me with it?
Any piece of help will be appreciated.
Thanks in advanced
Tamir.
 

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