How do I close the Shapes window of the Drawing Control?

P

Pete

I have a Visio Drawing Contrrol dropped on a form. The control shows
the main page, and it shows the Shapes window which displays stencils.
I can open and close stencils programmatically, but I cannot figure
out how to close the Shapes window. If I close the stencil, the
Shapes window remains, just blank. If I manually close it, via the
'X' in its taskbar, when I programmatically open a stencil, Visio
automatically opens the Shapes window to display it. Can someone clue
me in about what identifier I use to control the Shapes window?

I also tried opening and closing it in Visio while recording a macro,
but no code was produced.

Thanks, Pete
 
M

Mai-lan [MS]

Hi, Pete: You can try something like this:
Sub ShapeSearchHide()

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

End Sub

Thanks,

Mai-lan
 
P

Pete

Mai-lan,

Thanks for the quick response. I have a line like that already:

const int VISWINID_SHAPESEARCH =
(int)Visio.VisWinTypes.visWinIDShapeSearch;
VisApp.ActiveWindow.Windows.get_ItemFromID(VISWINID_SHAPESEARCH).Visible
= false;

But that just closes the ShapeSearch window at the top of the Stencil
pane. It does not close the Stencil pane itself. I want to close the
whole thing so that the Visio control displays nothing but the drawing
page itself.

Pete
 
M

Mai-lan [MS]

Hi, Pete: You're on the right track. The Find Shape window is one of the
windows in the windows collection. You'll need to iterate through all the
windows in the collection, and close each of the stencils within it. The
stencil pane is UI only, there is no automation "window" object for it. To
close the stencil pane, you have to close each of the stencils within it.

Mai-lan
--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Pete said:
Mai-lan,

Thanks for the quick response. I have a line like that already:

const int VISWINID_SHAPESEARCH =
(int)Visio.VisWinTypes.visWinIDShapeSearch;
VisApp.ActiveWindow.Windows.get_ItemFromID(VISWINID_SHAPESEARCH).Visible
= false;

But that just closes the ShapeSearch window at the top of the Stencil
pane. It does not close the Stencil pane itself. I want to close the
whole thing so that the Visio control displays nothing but the drawing
page itself.

Pete







"Mai-lan [MS]" <[email protected]> wrote in message
Hi, Pete: You can try something like this:
Sub ShapeSearchHide()

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

End Sub

Thanks,

Mai-lan
 
M

Mai-lan [MS]

Here's some C# code that demonstrates how to turn off the stencil pane
entirely:

private void button2_Click(object sender, System.EventArgs e)

{

Microsoft.Office.Interop.Visio.Document myDocument =
axDrawingControl1.Document;

Microsoft.Office.Interop.Visio.Application myApplication =

axDrawingControl1.Window.Application;

Microsoft.Office.Interop.Visio.Documents myDocuments =
myApplication.Documents;

Microsoft.Office.Interop.Visio.Windows myWindows =
myApplication.Windows[1].Windows;

Microsoft.Office.Interop.Visio.Window myWindow = null;

short numWindows = myWindows.Count;

for(short i = 1; i <= numWindows; i++)

{

myWindow = myWindows;

myWindow.Visible= false;

}

}

Mai-lan
--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Mai-lan said:
Hi, Pete: You're on the right track. The Find Shape window is one of the
windows in the windows collection. You'll need to iterate through all the
windows in the collection, and close each of the stencils within it. The
stencil pane is UI only, there is no automation "window" object for it. To
close the stencil pane, you have to close each of the stencils within it.

Mai-lan
--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Pete said:
Mai-lan,

Thanks for the quick response. I have a line like that already:

const int VISWINID_SHAPESEARCH =
(int)Visio.VisWinTypes.visWinIDShapeSearch;
VisApp.ActiveWindow.Windows.get_ItemFromID(VISWINID_SHAPESEARCH).Visible
= false;

But that just closes the ShapeSearch window at the top of the Stencil
pane. It does not close the Stencil pane itself. I want to close the
whole thing so that the Visio control displays nothing but the drawing
page itself.

Pete







"Mai-lan [MS]" <[email protected]> wrote in message
Hi, Pete: You can try something like this:
Sub ShapeSearchHide()

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

End Sub

Thanks,

Mai-lan
--
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

I have a Visio Drawing Contrrol dropped on a form. The control shows
the main page, and it shows the Shapes window which displays stencils.
I can open and close stencils programmatically, but I cannot figure
out how to close the Shapes window. If I close the stencil, the
Shapes window remains, just blank. If I manually close it, via the
'X' in its taskbar, when I programmatically open a stencil, Visio
automatically opens the Shapes window to display it. Can someone clue
me in about what identifier I use to control the Shapes window?

I also tried opening and closing it in Visio while recording a macro,
but no code was produced.

Thanks, Pete
 
P

Pete

Thanks, Mai-Lan. I was having trouble grasping how the panes were
organized. I noticed that using your code as is opened and closed ALL
the available windows, like Pan & Zoom, Custom Properties, etc., so I
modified it by looking for windows with a certain Caption that
matched.

I have one more question, since it seems that Visio handles these
panes a little non-intuitively. I have a menu item that allows the
user to make the stencil window visible or not. There is also an X on
the window so that the user can manually close it. However, my menu
item will remain checked unless I can catch that event. I have looked
at the events for the Visio drawing control, but can't see one that
would notify me when one of these windows is opened or closed
(BeforeWindowClosed only fires when the main drawing control is
exiting). Any ideas on how I could keep my menu item in synch with
the visible status of the stencil window?

Thanks,
Pete
 
M

Mai-lan [MS]

Hi, Pete: Try the ViewChanged event. Also, you can use the VIsio 2002 SDK's
eventmonitor with the Visio 2003 client application. You won't see the new
events in Visio 2003 but it does help to be able to monitor the ones (like
ViewChanged) that were in the product before.

Thanks,
Mai-lan
 
P

Pete

Mai-lan, thanks again for the reply. I tried what you suggested, and
ran into some issues:

1 - The ViewChanged event only fires when something happens to a
window that is docked. For that, I was able to add code that would
listen for that event, and when it occurred, check the Visible status
of each window and synch up the Checked property of the appropriate
menu items.

2 - For floating windows, the EventMonitor indicates an event
"BeforeWindowClose" gets fired. However, the Visio Drawing Control
has an event called "BeforeWindowClosed" (with a D at the end). This
drawing control event does NOT fire when a floating window is closed.
So I am still in the same position with windows that the user has
undocked.

3 - It seems inefficient to have an event handler that must loop
through all the available windows to check their Visible property each
time the view is changed. In my program, that will happen quite
frequently. Is there no way to have each window throw it's own event
when it is opened or closed? Can this only be done at the higher
level of the drawing control? Is that something that will be changed
in the future? Now that Visio can be used as an ActiveX control, this
sort of thing will come up often, I think.

Thank you for all your help,
Pete
 

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