Location of page within drawing window

G

gurry

Hi,

I'm trying to place a small window next to each shape in a drawing. It
is meant to display certain information about that shape. I intend to
achieve this by making the said window a child of the drawing window
in which the page lies (using the SetParent function call). Then I
would calculate its location w.r.t. the drawing window such that it
ends up being placed next to the shape.

My problem is, Visio API doesn't give me a shape's location with
respect to the drawing window coordinates; it only provides that with
respect to the page coordinates. But that's not a problem. I could
compute the shape position w.r.t. the drawing window coordinates if I
could find where the page itself is located in the drawing window.
However, the Visio API doesn't seem to have any function for such a
purpose.

I have searched the SDK help files but being a relative newbie to
Visio development, couldn't find much relevant information. So I'll be
very grateful if you guys here could tell point me to a suitable Visio
API function.

Thanks in advance.
~Gurinder
 
G

gurry

Thanks a lot John. Your suggested method works perfectly.

Thanks Al for your suggestion about datagraphics, too. However, I've
read that you can't create them programmatically and my "information
window" has to be neccesarily created that way. Secondly, there's a
chance that my addin will l have to run on Visio 2003 in addition to
2007. Therefore I don't think I can use datagraphics.
 
G

gurry

By the way, while I'm at it, may be I'll ask you about another related
problem as well.

To locate the information window within the drawing window this is
what I'm doing. First I set the parent-child relationship this call:

SetParent(infoWindow.Handle.ToInt32(),
visDrawingWindow.WindowHandle32)

Later I set the infoWindow's location within its parent with this
code:

infoWindow.Top = 0
infoWindow.Left = 0

(Here I've assigned 0 to Top and Left only for simplicity. In my
actual code the location values are computed by an algorithm)

Trouble is, the above code is producing weird behaviour. The Top and
Left of infoWindow end up being set to some random numbers, not 0. But
even stranger is the fact that when I change just the Top, the Left
too gets automatically changed! To a random number of course.

My suspcion is this is because of the difference in the types of the
two windows. The infoWindow is a .Net form and the Visio drawing
window is not. So SetParent is screwing up things here. However, I'm
still do not understand why this is happening and how to fix this.

I've searched google for this and found that people have similar
problems with SetParent (in the context of .Net forms). But didn't
find any answers to my particular problem or even anything close which
I could then extend to my case.

So may be I should ask you guys if you know how to fix this.

Thanks again.
~Gurinder
 
G

gurry

Umm... I asked too soon I guess. With a little more experimentation I
discovered that for SetParent to work correctly in the above context,
you must set the TopLevel property of the child form to false. That
fixes the problem totally.

So please ignore my preceding post.
 

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