在visio中是否有办法在演示模式下点击另一个形状时显示隐藏形状?

问题描述 投票:0回答:1

我正试图使用Visio 2016做一个非常基本的用户界面线框。 我想做的事情是,当我点击一个按钮时显示一个对话框,然后当我点击对话框中的 "确定 "时隐藏该对话框。 我之前的做法是将整个页面完全复制,然后将我想要的东西添加到新的页面中,并使用 "超链接 "选项。 如果有一种方法可以在我点击另一个形状时显示或隐藏一个形状,那就方便多了。 有没有这样的功能?

visio
1个回答
0
投票

在演示模式下?不,在演示模式下几乎没有可用的交互。


0
投票

你可以让一些代码在全屏模式下运行。在下面的示例中,我已经钩住了应用程序的MouseMove事件。当鼠标在形状上移动时,它会使你所处的形状的轮廓变大。

你可以通过在页面上画一堆矩形,然后在全屏模式下移动鼠标来测试代码。

不过我没能在全屏模式下捕获MouseDown。

更多的注释在代码的注释中!

Option Explicit

'// Notes:
'//
'// - This code works in full screen mode!
'// - The mouse-up code doesn't work if you drag the shape,
'//   (which won't be an issue in full-screen mode!)

Dim WithEvents m_visApp As Visio.Application

Private m_visShpMouseDown As Visio.Shape
Private m_lineWeightFormulaU As String

Private Sub Document_RunModeEntered(ByVal doc As IVDocument)

  '// Toggle RunMode on and off via the blue triangle button just
  '// right of the Stop/Reset button. This lets you reset the
  '// code without closing and opening the file every time! Also,
  '// this proc runs when you open the file, so m_visApp will
  '// be set up to receive events!

  Set m_visApp = Visio.Application

End Sub

Private Sub m_visApp_MouseMove(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal y As Double, CancelDefault As Boolean)


  Dim pg As Visio.Page
  Set pg = m_visApp.ActivePage
  If (pg Is Nothing) Then GoTo Cleanup

  Dim shp As Visio.Shape
  For Each shp In pg.Shapes

    If (shp.HitTest(x, y, 0)) Then

      '// The mouse is over a shape.

      If (shp Is m_visShpMouseDown) Then
        Debug.Print "MouseMove over same shape! " & DateTime.Now
        GoTo Cleanup
      Else

        Debug.Print "MouseMove over shape! " & DateTime.Now

        '// Restore any previously mouse-overed shape:
        Call m_restoreShape

        '// Save the original lineweight and change it to
        '// something thicker:
        m_lineWeightFormulaU = shp.CellsU("LineWeight").FormulaU
        Set m_visShpMouseDown = shp

        '// Make the lineweight thick:
        shp.CellsU("LineWeight").FormulaForceU = "5pt"

        GoTo Cleanup

        '// Note: the above won't change the lineweights
        '// for all shapes in a group. If you intend to use
        '// this on grouped shapes, you'll have to recurse
        '// into the group, which makes things a bit more
        '// complicated!


      End If

    End If

  Next shp


  Call m_restoreShape

Cleanup:
  Set shp = Nothing
  Set pg = Nothing
End Sub

Private Sub m_restoreShape()

  If (m_visShpMouseDown Is Nothing) Then Exit Sub

  '// Restore the shape's original lineweight:
  m_visShpMouseDown.CellsU("LineWeight").FormulaU = m_lineWeightFormulaU

  '// Clear the mouse-down variables:
  Set m_visShpMouseDown = Nothing
  m_lineWeightFormulaU = vbNullString

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.