Visio Drawing Control, Access 2003, VBA, anchor or form resize behavior

G

gunslingor

I have been struggling for 2 weeks now. I have a visio drawing control
11.0 in an access 2003 form. All I want to do is set things up so that,
when the form is resized, the visio drawing control also resizes
accordingly. I have tried a number of things. nothing seems to work.
Please please help if you know anything.

Thanks.
 
A

AlEdlund

I use this in a vb.net app. It should be close to what you need.
al


' our basic rack drawing page size
Const constPageWidth As String = "29ft. 4in."
Const constPageWidthExample As String = "11ft"
Const constPageHeight As String = "22ft. 8in."
Const constPageHeightExample As String = "8.5ft"
Const constDrawingScale As String = "1ft"
Const constPageScale As String = ".375in"
Const constPageScaleExample As String = "1in"
Const constDrawingScaleType As String = "1"

' these are for understanding where we have put the
' control in the form
Const constDrawStartX As Integer = 40
Const constDrawStartY As Integer = 40
Const constDrawHeight As Integer = 100
Const constDrawWidth As Integer = 80

Private Sub InitTheDrawingControl()

m_visApp = Me.AxDrawingControl1.Window.Application
m_visDoc = Me.AxDrawingControl1.Document

m_visWin = Me.AxDrawingControl1.Window
m_visWin.ShowGrid = False
m_visWin.ShowPageTabs = True
m_visWin.ShowRulers = True
m_visWin.ShowScrollBars = True
' make sure the control does not change the pagesizebehavior
Me.AxDrawingControl1.PageSizingBehavior =
Visio.VisPageSizingBehaviors.visNeverResizePages

Dim intPgCt As Integer = m_visDoc.Pages.Count

Dim visPage As Visio.Page = Me.AxDrawingControl1.Window.Page
visPage.NameU = "ShapeData"
System.Windows.Forms.Application.DoEvents()

setSitePageSize(visPage)

AxDrawingControl1.Width = Me.Width - constDrawWidth
AxDrawingControl1.Height = Me.Height - constDrawHeight

' make sure the drawing control is placed correctly in the form
Dim locStart As System.Drawing.Point
locStart.X = constDrawStartX
locStart.Y = constDrawStartY
AxDrawingControl1.Location = locStart

AxDrawingControl1.Width = Me.Width - constDrawWidth
AxDrawingControl1.Height = Me.Height - constDrawHeight


End Sub

Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.ResizeEnd

Me.Cursor = Cursors.WaitCursor
System.Windows.Forms.Application.DoEvents()

' make sure the drawing control is placed correctly in the form
Dim locStart As System.Drawing.Point
locStart.X = constDrawStartX
locStart.Y = constDrawStartY
AxDrawingControl1.Location = locStart

AxDrawingControl1.Width = Me.Width - constDrawWidth
AxDrawingControl1.Height = Me.Height - constDrawHeight


Me.Cursor = Cursors.Default

End Sub
 
G

gunslingor

I tried using this

-->on form load
Me.Width=12000
Me.detail.Height =12000

AxDrawingControl1.Width=10000
AxDrawingControl1.Height=10000

-->on form resize
AxDrawingControl1.Width = Me.Width - 2000
AxDrawingControl1.Height = Me.detail.Height - 2000

But it doesn't work. For one, the documentation doesn't clearly tell
what units are expected. I think both are in twips, but I still am not
sure since it has functioned as expected. I tried using twipstopixels
conversion, but since this is VBA, I had to create it from scratch and
it isn't working. Also, just to "form load" operation seems to be
failing in that I am getting values different than 12000 (eg 14392).
Plus, the subtraction operation, for some reason, often results in an
addition since AxDrawingControl1.Width/Height is often higher than
expected. I have gotten the drawing control to resize on form_resize,
however, it seems to grow to large on form expand and then even grows
larger on form collapse (the opposite of what is supposed to happen)
 

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