Controlling Size of Drawing Window Versus Size of Page

N

NovemberJim

I am programmatically creating Visio pages in the Visio Drawing Control at
runtime, but the control's drawing window is so much larger than the pages
(5" x 10") I am creating that scroll bar behavior is very undesirable.
Namely, all clicks on the scroll-bar arrows cause movements of the page that
are much too large to allow accurate positioning of the drawing in the
window. Zooming doesn't solve the problem. Fundamentally the drawing window
is roughly 3 times the size of my page in both height and width. My
question is: how can I programmatically make the size of the drawing
control's window smaller, so that my pages fill more of the window? I have
tried using the window's SetWindowRect method, but I get an error message
"The operation cannot be performed while doing in-place editing". Is there
some scale-setting method to make my page fill more than 1/9 of the area of
the window?
 
N

NovemberJim

Thanks, but that suggestion didn't fix the problem. Below is a code snippet
in which I set drawingControl.Window.Zoom=-1. The "before" and "after"
rectangles are exactly the same:

WindowRect = (1,1,800,400)
ViewRect = (-7.8, 11.2, 24.0, 11.5)

From the ViewRect, the size of the problem begins to be apparent. I've got
a standard 8.5"x11" page in the window, but the drawing window's size is
roughly 24" x 27", which means it has 9 time the area as my page. I
measured the size of the drawing window by scrolling to its top, bottom,
left, and right using the scroll bars. The ViewRect is, of course, smaller
than the drawing window, but it gives a numerical indication of the size of
the drawing window.

Here's the code snippet that I inserted just after InitializeComponents() in
a Windows Form constructor in VB.NET:

' Do experiment on controlling Drawing Window size versus Page Size
' Page size in this case is a default 8.5 x 11 portrait page

Dim left, top, width, height As Integer
Dim dleft, dtop, dwidth, dheight As Double
Dim sp As String = ", "

Me.drawingControl.Window.ShowPageTabs = False
' Get Window and View Rectangles before trying to change things
Me.drawingControl.Window.GetWindowRect(left, top, width, height)
Me.drawingControl.Window.GetViewRect(dleft, dtop, dwidth, dheight)
MsgBox("BEFORE: " & vbCrLf & _
"WindowRect=(" & left & sp & top & sp & width & sp &
height & ")" & vbCrLf & _
"ViewRect = (" & dleft & sp & dtop & sp & dwidth &
sp & dheight & ")")

' Try to change things to reduce the large amount of dead space
in window
Me.drawingControl.Window.Zoom = -1

' Get Window and View Rectangles after trying to change things
Me.drawingControl.Window.GetWindowRect(left, top, width, height)
Me.drawingControl.Window.GetViewRect(dleft, dtop, dwidth, dheight)
MsgBox("AFTER: " & vbCrLf & _
"WindowRect=(" & left & sp & top & sp & width & sp & height
& ")" & vbCrLf & _
"ViewRect = (" & dleft & sp & dtop & sp & dwidth & sp &
dheight & ")")
 

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