Hello Franck, thank you for you help offer :)
here is our code:
toolbar definition in manifest.xsl:
...
<xsf:toolbar caption="EditView" name="Toolbar_EditView">
<xsf:button name="SaveAndQuit" caption="Speichern und Beenden"
icon="3"></xsf:button>
<xsf:button name="PrintView" caption="Druckansicht"
icon="230"></xsf:button>
<xsf:button name="Cancel" caption="Abbrechen"
icon="231"></xsf:button>
</xsf:toolbar>
...
Our toolbar config routine contains the following code to
disable/enable the toolbar:
...
BindingFlags MethodFlags = BindingFlags.GetProperty |
BindingFlags.DeclaredOnly | BindingFlags.Public |
BindingFlags.Instance;
ObjectWrapper commandBars =
(ObjectWrapper)thisApplication.ActiveWindow.CommandBars;
CommandBar cmdbEdit= (CommandBar)commandBars.InvokeByName("Item",
MethodFlags, new object[] {"EditView"}, null);
cmdbEdit.Enabled= false;
....
if we run this code in the OnLoad event, the following exception is
thrown:
System.Reflection.TargetInvocationException
Ein Aufrufziel hat einen Ausnahmefehler verursacht.(*TRANSLATION: A
calling target has thrown an exception*)
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, CultureInfo culture)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper.InvokeByName(String
name, BindingFlags invokeAttr, Object[] args, CultureInfo culture)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper.InvokeByName(String
name, BindingFlags invokeAttr, Object[] args, CultureInfo culture)
....
if we execute the same code manually using a button from within the
loaded form, it executes without problems.
Where is the problem?
Waiting hopefully for you answer,
Best regards,
Daniel
Franck Dauché - 29 Sep 2005 16:59 GMT
Hi,
OK I see what your problem is. You are mixing 2 ways to handle toolbars.
You created a custom toolbar by modifying the Manifest.xsf (which means that
is now hard coded in your form), and you are trying to reach it by code as if
it was an Office toolbar.
To be able to manipulate your toolbar by code as you wish to do, you need to
remove the lines of code in your manifest, and you need to add an office
toolbar.
Instead of using
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsd
kDisplayCustomToolbar_HV01083303.asp
Try to use this reference to create your toolbar
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/h
tml/OfficeInfoPathCustomizingInfoPathMenusandToolbars.asp
Hope that it helps you.
Franck Dauché
> Hello Franck, thank you for you help offer :)
>
[quoted text clipped - 58 lines]
>
> Daniel
Brühno - 30 Sep 2005 20:07 GMT
Many, many thanks, Franck!!!! Your hint has helped us solving our
problem, I am so happy :o)
Franck Dauché - 30 Sep 2005 20:56 GMT
You are very welcome. I am glad I could help you.
If you are using IE, go to
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.
public.infopath&cat=en_US_bd40fd00-b6cc-4a82-a6e5-b9445cc9367d&lang=en&cr=US
to access this newsgroup and don't hesitate to rate my post so that other
can find the answer quickly.
Franck Dauché
> Many, many thanks, Franck!!!! Your hint has helped us solving our
> problem, I am so happy :o)