Stencils Don't Open Docked Top 2003

P

PaulV

In Visio 2002 when I have stencils docked to the top of
the screen and then open a new stencil it is by default
also docked top. In 2003 whenever I open a new stencil it
is docked left leaving the already open stencils docked
top. Also the shape search window gratuitously comes back
on if it was off. Is there any way to fix this via
settings or VBA or whatever?
 
D

Dawn Wright [MSFT]

Paul,

I cannot reproduce the behavior that you're seeing. When stencils are
docked to the top, opening a new stencil should cause it to merge in with
the other stencils and create a new tab at the bottom of the stencil window
(this type of merging behavior is new to 2003). Can you give step-by-step
instructions for how to see this problem?
 
P

PaulV

Dawn,
Thanks for looking as this.
Here's the scoop...
----------------

Behavior attempting to achieve:

A template with two stencils open docked top (with tabs).
When opening
another stencil, it opens as another tab in the already
docked top set. This
behavior independent of where shape window was docked last
time Visio was
run. Shape search window not visible. In Visio 2002 this
achieved by
starting with a blank drawing, opening the desired
stencils, docking the
shape window top and saving as template. Of course in
2002 the very cool tabs
are not there.

----------------

Visio 2003 Attempt 1:

Use Visio 2002 approach. Open 2 stencils. Dock Shapes
window top. Use VBA:
ActiveWindow.Windows.ItemFromID
(Visio.visWinIDShapeSearch).Visible = False
to kill the shape search window. Save as template.
Result:
When the template is opened, the correct stencils are
opened, but the
Shapes window is docked wherever it was the last time
Visio was run. The
Shape Search window is visible.

----------------

Visio 2003 Attempt 2:

Start Visio with blank drawing. Open 2 stencils. Drag
the individual stencils
(not the Shapes window) to the top where they are docked
with tabs. Use VBA:
ActiveWindow.Windows.ItemFromID
(Visio.visWinIDShapeSearch).Visible = False
to kill the shape search window. Save as template.
Result:
When the template is opened, the correct stencils are
opened and they are
docked top with tabs. They are docked top independent of
the location of
the shapes window. In addition, however, the Shape Search
window is visible
docked wherever it was when Visio was last run. You can
use VBA:
ActiveWindow.Windows.ItemFromID
(Visio.visWinIDShapeSearch).Visible = False
to kill the shape search window, but when you then open
another stencil
the a new shapes window appears and the new stencil is
there.

----------------

Other thoughts:

Is there a VBA way to set the location of the shapes
window?

Is there a way to make the shapes window location
associated with the drawing
or template instead of the last time Visio was run?

Am I missing something trivial here?
 
D

Dawn Wright [MSFT]

Paul,

In Visio 2003, the Shapes Window is the default container for newly opened
stencils and is a new built-in window inside Visio, similar to the Pan &
Zoom and other built-in windows. This allows users to turn the window off
(i.e. "close" it) without losing the state of the stencils inside. The
Shapes Window can be turned on again by choosing the View > Shapes Window
menu toggle. We found that users sometimes want to hide the stencil window
to gain screen real estate, but in the past, when the window was closed, all
of the stencil documents were also closed and users were unable to figure
out how to turn them on again (the stencils needed to be reopened from the
file menu).

The new Shapes Window acts like the other built-in Visio windows. Similar
to the other window settings in the View menu, these are application
settings, so when the window is toggled off, it is off for the entire
application, and all newly opened documents will have this window turned
off. Similarly, the positioning is an application-wide setting. An
application-wide setting cannot be saved with the document. This is why the
Shapes Window opens in the location that the user last put it, despite
positioning that was in effect when the document was saved.

From VBA, you can change the docking to the top by setting the window's
WindowState to visWSDockedTop. If you're authoring a template, you will
want to carefully consider whether you really want to override the user's
settings, since the user may have specific reasons to position the window in
a particular location (i.e. screen real estate issues on a Tablet PC or
other screen where Visio is opened in a different orientation, accessibility
preferences, etc).

The Shape Search box inside this window can be turned off on a per-window
basis. So if you turn it off for one window, it will still show inside
another window. Since there can be multiple windows (i.e. "views") into a
single document, you can have one view of the document that shows the search
box and another view of the document without a search box. This setting can
be changed from VBA as you described:

ActiveWindow.Windows.ItemFromID(Visio.visWinIDShapeSearch).Visible = False

Window settings also cannot be saved with the document. As a result, you
would need to hide the search box each time a window is opened if you never
want it to display.

I hope this helps explain the behavior of these new features.
 
G

Guest

Dawn,

(see further question at end)
Thanks for the detailed explanation. This helps. Lot's
of design tradeoffs here. I've played a bit with various
combinations and find some behaviors to be not what I
would expect, but accept that and hope others understand
it. They seem to be around the case where there are
multiple shapes windows on the screen, but I can't
characterize very well. Appreciate the caution about
changing user settings -- something I must evaluate.
Please read on for the "near solution" and a further
question.

Near solution.

Open blank drawing.
Open desired stencils.
Save template.
Use VBA:
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).WindowState = visWDDockedTop
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).Visible = False

Having done this, the remaining problem is that you cannot
change the height of the shapes window to make it
shorter. Curiously if you now use Visio menu command:
View, Shapes Window
to toggle the shapes window off then on you can shorten it.

Is there VBA code I could use to shorten the window?

Thanks.

Paul
-----Original Message-----
Paul,

In Visio 2003, the Shapes Window is the default container for newly opened
stencils and is a new built-in window inside Visio, similar to the Pan &
Zoom and other built-in windows. This allows users to turn the window off
(i.e. "close" it) without losing the state of the stencils inside. The
Shapes Window can be turned on again by choosing the View
Shapes Window
menu toggle. We found that users sometimes want to hide the stencil window
to gain screen real estate, but in the past, when the window was closed, all
of the stencil documents were also closed and users were unable to figure
out how to turn them on again (the stencils needed to be reopened from the
file menu).

The new Shapes Window acts like the other built-in Visio windows. Similar
to the other window settings in the View menu, these are application
settings, so when the window is toggled off, it is off for the entire
application, and all newly opened documents will have this window turned
off. Similarly, the positioning is an application-wide setting. An
application-wide setting cannot be saved with the document. This is why the
Shapes Window opens in the location that the user last put it, despite
positioning that was in effect when the document was saved.

From VBA, you can change the docking to the top by setting the window's
WindowState to visWSDockedTop. If you're authoring a template, you will
want to carefully consider whether you really want to override the user's
settings, since the user may have specific reasons to position the window in
a particular location (i.e. screen real estate issues on a Tablet PC or
other screen where Visio is opened in a different orientation, accessibility
preferences, etc).

The Shape Search box inside this window can be turned off on a per-window
basis. So if you turn it off for one window, it will still show inside
another window. Since there can be multiple windows (i.e. "views") into a
single document, you can have one view of the document that shows the search
box and another view of the document without a search box. This setting can
be changed from VBA as you described:

ActiveWindow.Windows.ItemFromID
(Visio.visWinIDShapeSearch).Visible = False
 
D

Dawn Wright [MSFT]

Paul,

It looks like you've found a bug there. First you dock to the top and then
you hide the search box, but the shape window resize logic isn't updated to
become aware that the you hid the search box, so it still thinks that the
window has only one row of masters, when it really has two.

As a workaround, first hide the search box, then dock to the top. Or
perform some other action that forces the window to update (such as turning
it off and on, as you've discovered).
 
P

PaulV

Dawn,

Thanks for continuing to pursue this. Was hoping to not
end up in bug land. Have a scary solution and a couple of
more questions.

After much experimentation got a sequence that seems to
work. Every line is important even though I don't fully
understand why.

Public Sub yyy()
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).Visible = False
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).WindowState = _
visWSDockedTop
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).Close
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).Visible = True
ActiveWindow.Windows.ItemFromID _
(Visio.visCmdShapesWindow).Visible = False
End Sub

There is a nasty side effect -- when you then open
Shapes, Block Diagram, Basic Shapes
you get an error:

Microsoft Office Visio
An invalid arugment was encountered.

OK seems to lead to no problems with shapes. How scared
should I be of this?
Opening other stencils seems fine.

--------------------

Also curious about the two Visio constants:
Visio.visCmdShapesWindow
Visio.visWinIDShapeSearch

Both seem to map to the same value. Your note and some
tech bulletins
reference the later while Graham Wideman's book references
the former.
They seem to impact both the Shape Search sub window as
well as the overall
Shapes window which is pretty confusing. Am I missing
something here? Is one or the other preferred?
 
D

Dawn Wright [MSFT]

Paul,

I found that the following worked:

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
ActiveWindow.Windows.ItemFromID _
(Visio.visWinIDShapeSearch).Visible = False
ActiveWindow.Windows.ItemFromID _
(Visio.visWinIDShapeSearch).WindowState = visWSDockedTop
End Sub

Does that work for you?
Also curious about the two Visio constants:
Visio.visCmdShapesWindow
Visio.visWinIDShapeSearch

Constants that start with 'visCmd' are command IDs, typically used for
passing to DoCmd. Firing this command to turn on/off the shapes window will
affect all shapes windows and their children (stencil windows and shape
search window), so it doesn't apply to a single window. You can create
multiple shapes windows, as in the scenario you described in "Attempt 2" in
your 11/28 message.

Constants that start with 'visWinID' are window IDs, and they are what you
should use in this case since you're looking up a window by ID.
visWinIDShapeSearch is the ID that uniquely identifies the single shape
search window.

Then you're probably wondering why the docking applies to the overall shape
search window when you specify the visWinIDShapeSearch window. That's
because WindowState applied to a window inside a merged anchor window
affects the overall parent window. You could instead set the WindowState on
one of the child stencil windows inside the shape window, and that would
have the same effect.
 
D

Dawn Wright [MSFT]

Paul,

Sorry, I should probably clarify this further. These constants do have the
same exact underlying value, which is why it works no matter which constant
you use.

Visio.visCmdShapesWindow
Visio.visWinIDShapeSearch

They don't invoke different actions, but the name of the constants imply
that they should be used in different contexts. One is prefixed with
'visCmd' indicating that it's a command ID, and the other is prefixed with
'visWinID' indicating that it's a window ID. When you use an API that takes
a window ID, you should use visWinIDShapeSearch, or if the API wants a
command ID, then you should use visCmdShapesWindow. The reason this is done
is so that your program does not change if the underlying value for the
constant ever changes in a future version. Visio does try to maintain the
same mappings for constants across multiple versions, but the best guarantee
you have for making sure that your program is compatible with future
versions is to use constants instead of hard-coded numbers, and make sure
you use the correct constants for the context you're working in.

Calling Close with visCmdShapesWindow will work and have the same effect as
using visWinIDShapeSearch, but using visWinIDShapeSearch is technically
correct since Windows.ItemFromID is wanting you to give it a window ID.

I hope this explanation helps.
 

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