Screen Refresh - or lack of

Started by Torquemada, December 08, 2010, 01:27:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Torquemada

Hi,

I am by no means a Visio Jedi, but on the other hand I'm starting to wonder why this is so difficult...

I've made some command buttons in Visio 2007 to show/ hide several layers of stuff - but when I use them, the layers are enabled/ disabled as they should be, but what's actually on the screen usually doesn't change.

Of course, my instinct in these situations is to press F5...but of course, MS have made that the key for 'full screen mode'. This does, however, prompt the system to redraw and my diagram comes up as it should be.

My question is - is there some command I'm missing in the script to redraw the screen after enabling disabling layers?

Here's a snippet of the code - any suggestions gratefully received!

Dim LayersObj As Visio.Layers
Dim LayerObj As Visio.Layer
Dim LayerName As String
Dim LayerCellObj As Visio.Cell
Set LayersObj = ActivePage.Layers
For Each LayerObj In LayersObj
LayerName = LayerObj.Name
' Debug.Print LayerName
  If LayerName = "Cab 21" Then
    Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
LayerCellObj.Formula = True Or 1
  End If
  If LayerName = "Cab 21 Power" Then
    Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
LayerCellObj.Formula = False Or 0
  End If
  If LayerName = "Cab 21 Network" Then
    Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
LayerCellObj.Formula = False Or 0
  End If

End Sub

aledlund

Been there, done that, don't want to go back. When stepping into that set of issues the order that the layers are on the page comes into effect, you may be turning off layers that are under other visible layers and the changes cannot be seen. David Parker did an interesting article in this area.

http://davidjpp.wordpress.com/2007/10/08/toggling-layers-on-and-off/

al
ps chris likes us to use code tags
http://visguy.com/vgforum/index.php?topic=89.0

Torquemada

Oh crikey, thanks for the astonishingly fast reply!  :)

Double-Cheers also for the code tags

I did play with the toogle article you linked, but I'm not a macro jedi, so outside of using the example I got lost pretty quickly - for example, one toggle button I created had seventeen layers on it, making the button text list quite large - and do I know how to relabel the button? Of course not, even if I knew how to expose the code. And not long after that, it decided to stop responding completely when clicked...so I ran away...

In any case, My problem doesn't seem to be related to front/ back issues - the two other methods I've tried (such as the earlier example) don't just not show/ hide certain layers; they don't show anything - some work and some don't, with no apparent connection or clues. For example, if I have four network cabs displayed, and have a 'hide' button for each, I can hide all of them - but 'show all' does nothing. Clicking on another hide button (even though they're all already hidden) makes visio redraw the screen, and presto, they all come back (and the 'show all' button then works, filling in the hidden one I'd just clicked). The layer settings are visibly correct, so the buttons/ scripts are working - it's just Visio that isn't listening.

Of course, if there was a script command to redraw/ refresh the screen, I could work around this - but googling has brought up nothing. It also seems a bit silly to have a full-screen mode where you can't click on any created buttons as visio thinks you want to look at the next page.

Does Visio 2010 fix any of these problems?

aledlund

can you share the drawing/vba code? please not publicly or with confidential information.
al

Nikolay

Hi Torquemada,

If something is not repainted properly in Visio, you can try the following trick: set zoom to +1%, and then set it back:


    Dim a As Double, b As Double, c As Double, d As Double
    ActiveWindow.GetViewRect a, b, c, d
    ActiveWindow.SetViewRect a, b, c, d + 0.01
    ActiveWindow.SetViewRect a, b, c, d


May (may!) work ;)

Torquemada

Nikolay, you are a Jedi and a scholar!

Thanks for the workaround, it works a treat - I will dance at your wedding etc. :-)

Nikolay

I'm not the author of this "redraw trick", Senaj Lelic is, so I guess I'm not really a Jedi but merely a padawan yet :)

Torquemada

Well, you were there with the knowledge when I needed it - he obviously has passed on what he has learned....so you're still a Jedi in my book  8)