P
PatternNut
Hi,
I can't figure out how to determine where exactly a selection lies on
screen.
I'm writing a VBA/VB6 add-in for MS Word. The add-in consists of a form
that highlights bits of text in a document and then allows the user to
change it. For instance, like a find and replace, it could find the
word "dog" in a document, select it and ask the user for a selection of
pre-programmed changes. Whereas Find and Replace only has one replace
option, this has several on a form for the user to choose between.
That works great... the problem is that sometimes the selected word in
the document is hard to see. The form is in front of the document, so
the selection in the text is behind it. It's not hidden or anything and
there's nothing wrong, but it means the user has to move the add-in
window in order to see the selection it is pointing to (and half the
time users end up getting confused and think there is nothing selected).
An obvious way to solve this is to reduce the size of the document
window so it sits on the same screen as the form. But that looks awful.
Microsoft have two great ways of solving this... and either of them
would be fantastic for me... but I can't begin to figure out how to
replicate this. The two ones they do are:
Find and Replace: When a point in the document is selected, the
find/replace dialog box moves to part of the screen where it is clear
the selection is not underneath. If I could work out the coordinates of
the selection, I could do something similar with my form, moving it the
way Microsoft move their find/replace dialog.
Spelling/Grammar: The selection always appears at the top of the window
- or rather, in between the top and the spelling dialog. If the
selection would be too low, then the window scrolls so that the
selection is still between the dialog and the top. Again, if I could
just figure out the location of the selection on the screen (ie 240
pixels by 640 pixels) then I could do the same for my form and make sure
they are okay together. But I can't figure out how.
I have no idea how to achieve anything like either of these. How can
you possibly tell where a selection is on screen... are there
co-ordinates? Can these then be related to the form to move it? How
can you scroll the document programmatically? Any advice at all would be
enormously helpful.
Thanks for any help you can offer.
PatternNut
I can't figure out how to determine where exactly a selection lies on
screen.
I'm writing a VBA/VB6 add-in for MS Word. The add-in consists of a form
that highlights bits of text in a document and then allows the user to
change it. For instance, like a find and replace, it could find the
word "dog" in a document, select it and ask the user for a selection of
pre-programmed changes. Whereas Find and Replace only has one replace
option, this has several on a form for the user to choose between.
That works great... the problem is that sometimes the selected word in
the document is hard to see. The form is in front of the document, so
the selection in the text is behind it. It's not hidden or anything and
there's nothing wrong, but it means the user has to move the add-in
window in order to see the selection it is pointing to (and half the
time users end up getting confused and think there is nothing selected).
An obvious way to solve this is to reduce the size of the document
window so it sits on the same screen as the form. But that looks awful.
Microsoft have two great ways of solving this... and either of them
would be fantastic for me... but I can't begin to figure out how to
replicate this. The two ones they do are:
Find and Replace: When a point in the document is selected, the
find/replace dialog box moves to part of the screen where it is clear
the selection is not underneath. If I could work out the coordinates of
the selection, I could do something similar with my form, moving it the
way Microsoft move their find/replace dialog.
Spelling/Grammar: The selection always appears at the top of the window
- or rather, in between the top and the spelling dialog. If the
selection would be too low, then the window scrolls so that the
selection is still between the dialog and the top. Again, if I could
just figure out the location of the selection on the screen (ie 240
pixels by 640 pixels) then I could do the same for my form and make sure
they are okay together. But I can't figure out how.
I have no idea how to achieve anything like either of these. How can
you possibly tell where a selection is on screen... are there
co-ordinates? Can these then be related to the form to move it? How
can you scroll the document programmatically? Any advice at all would be
enormously helpful.
Thanks for any help you can offer.
PatternNut