Toolbar customization problems; Sorry of the exhaustive posting

  • Thread starter R?my Apfelbacher
  • Start date
R

R?my Apfelbacher

Hi,

I experience some problems with a programmatically generated Toolbar
from my VSL addon and unfortunately elder postings on this newsgroups,
and study of the DVS didn't help me. May be because I did not
understand some points.
However, first I want to desribe the intention of the addon and some
relevant technical information of the solution before I describe the
problems I encounter with it.

The solution (working with Visio 2000, 2002 and 2003) should provide
an additional Toolbar to the Visio UI everytime Visio is started, and
show up several buttons, some of them being enabled or disabled
depending the content of a document. The additional Toolbar should
also stay accessible till Visio is closed (=quit/exit). Of course any
user customization of the Visio UI made before our solution is
installed, should be preserved. Furthermore user customization e.g.
new custom toolbars etc. after the installation should also be
preserved.
This is what I did. Our addon is launched at startup time of Visio,
because the path to our vsl is added to StartUp-Path and to the
Addons-Path settings of Visio. To both because the button icons
incorporated in the vsl are not found if the path is only added to the
StartUp-Path-setting. The additional Toolbar is generated when Visio
is Idle for the first time after startup because user made custom
toolbars are not detected before and the addon would thus 'overwrite'
them.
So our additional toolbar is present when Visio is started which was
intended. The following source code is a stripped down version of the
original code with only the relevant UI code.
To summarize the code:
1. get the correct UI object (referenced by FMCUI)
2. get the correct Toolbarset
3. add the additional Toolbar and apply settings (referenced by
FMCToolbar)
4. add buttons to the toolbar and apply settings
5. put the new UI in action on application level for the toolbar to
be visible while visio is running

---- start source code snippet ----
method to create the Toolbar of Class A called when Visio is Idle for
the first time after startup:

'CVisioApplication VisioApplication is a private attribute of
the class A'
'CVisioUIObject FMCUI is a private attribute of the class A'
'CVisioToolbar FMCToolbar is a private attribute of the class
A'
'CVisioToolbarItems FMCToolbarItems is a private attribute of
the class A'

// get the correct UI object and store a reference in FMCUI
// (the customtoolbars UI object or the copy of an
builtin-toolbars UI)
// and in order not to overwrite existing custom toolbars
CVisioDocument ActiveDocument;
VisioApplication.ActiveDocument( ActiveDocument );
CVisioUIObject DocUI;
ActiveDocument.CustomToolbars( DocUI );
if( DocUI.IsSet() ) {
DocUI.Clone( FMCUI );
} else {
CVisioUIObject AppUI;
VisioApplication.CustomToolbars( AppUI );
if( AppUI.IsSet() ) {
AppUI.Clone( FMCUI );
} else {
VisioApplication.BuiltInToolbars( visToolBarMSOffice, FMCUI );
}
}

// Determine the visibilty of the Toolbar - here Application
CVisioToolbarSets ToolbarSets;
FMCUI.ToolbarSets( ToolbarSets );
CVisioToolbarSet ToolbarSet;
ToolbarSets.ItemAtID( visUIObjSetDrawing, ToolbarSet );

// Create a new FMC Toolbar and store a reference into FMCToolbar
CVisioToolbars Toolbars;
ToolbarSet.Toolbars( Toolbars );
Toolbars.Add( FMCToolbar );

// Define Settings of new FMCtoolbar
FMCToolbar.putCaption( VBstr( FMCTOOLBARNAME ) );
...

// add several buttons
FMCToolbar.ToolbarItems( FMCToolbarItems );
e.g. ToolbarItems.Add( PreferencePaneButton );
and PreferencePaneButton.put*; for settings are preformed
...

// Make our new FMC Toolbar visible to Visio
VisioApplication.SetCustomToolbars( FMCUI );
}
---- end source code snippet ----


Now the problems.
P1. if there were user customizations before our solution is installed
the user customization stays for the first Visio launch. For all other
launches the user customization disappears.

P2. if the user does some customization after the installation, e.g.
adding a new toolbar, these customization are available at the next
launch of Visio but on consecutive launches they disappear, just like
problem P1.

P3. if the user does some customization after the installation, the
programmatically added additional toolbar behaves strangely. It is not
possible anymore to change the state of any of the buttons. They
simply become disabled. Michael Hunter stated in a previous post
(http://groups.google.de/groups?hl=de&lr=&ie=UTF-8&selm=e7v5f6y1AHA.1284@tkmsftngp03)
"When UI customizations are done both programmatically and manually
they "fight" and only one wins. The best workaround currently is to
re-apply your programmatic customizations when you detect they have
disappeared."
Unfortunately all attributes, the UIObject (FMCUI), the Toolbar
(FMCToolbar), the Buttons (e.g. PreferencePaneButton) etc. are all
valid (e.g. FMCUI.IsSet() == true and properties can be 'getted')! So
I don't know when to restart the above workaround.
But if the user customization takes place while a document was open,
closing it re-enables the additional toolbar and it works correctly!
The other way round when user customization takes place when no
document is opened the additional toolbar completely dissapears when a
document is opened.

P4. Even when re-applying the programmatic customizations (on user
demand in order to test if it works) I got strange behaviors. First I
delete the previously created ToolbarItems (buttons), the Toolbar
itself and the UIObject in order to re-create the additional toolbar
and not having several ones. The 'new' additional toolbar has only
buttons which are disabled which is not intended.

P5. There are Visio 2000 and Visio 2002 discrepancies in UI behavior.
Programmatically re-applying the customizations works fine in Visio
2000 if there were no user customization. With Visio 2002 the newly
created toolbar does not obey to the properties set (visibility).
Changes only occur if a document is closed or opened. (I did not test
it with Visio 2003)


Anyone out there who encountered similar problems and has some hints?

Thanx
Rémy
 

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