Menu bars in managed code

  • Thread starter Dan from Badgerland
  • Start date
D

Dan from Badgerland

Hi, Here is the C# code to disable menu bars can someone help me convert it
to vb.net? Thanks.

BindingFlags PropFlags = BindingFlags.GetProperty |
BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance;
object[] args3 = new object[] {"Menu Bar"};
CommandBar commandBarItem = (CommandBar)commandBars.InvokeByName("Item",
PropFlags, args3, null);
commandBarItem.Enabled = false;
 
D

Dan from Badgerland

I figured that out. Here is the code:

'============================================
' Remove All Menus
'============================================
Dim commandBars As ObjectWrapper = thisApplication.ActiveWindow.CommandBars()
'Set the expected values for flags for the InvokeMember calls
Dim flags As BindingFlags = BindingFlags.GetProperty Or
BindingFlags.DeclaredOnly Or BindingFlags.Public Or BindingFlags.Instance Or
BindingFlags.InvokeMethod

'Set arguments for InvokeMember calls
'Name of the toolbar (commandbar) that this button will be found on

Dim args As Object() = New Object() {"Menu Bar"}
'Get required commandbar
Dim commandBarItem As Object = commandBars.InvokeByName("Item", flags, args,
Nothing)
commandBarItem.enabled = False

Dim args1 As Object() = New Object() {"Formatting"}
'Get required commandbar
Dim commandBarItem1 As Object = commandBars.InvokeByName("Item", flags,
args1, Nothing)
commandBarItem1.enabled = False

Dim args2 As Object() = New Object() {"Standard"}
'Get required commandbar
Dim commandBarItem2 As Object = commandBars.InvokeByName("Item", flags,
args2, Nothing)
commandBarItem2.enabled = False
'============================================
' End of Remove All Menus
'============================================

My next question is where do I set them back on. I tried _shutdown and
finalize but it doesn't like that. I'm pretty sure I have to do this because
it whacked all my design time menus also. I deleted the file C:\Documents and
Settings\MY_USERNAME\Application Data\Microsoft\InfoPath\infopath.tbs to get
them back but don't want my users to have to do this. Thanks!
 
M

matt

Hi Everybody

I am designing a form that has a customized Task pane on it.HTML of of
this take pan is a data access page created by Access 2003.I keep
getting warning that my security level is not enough.The whole thing
is on my machine, the Form, the access and data base. I check the
fully trusted option of the form; play with the internet explorer
security options. But nothing works.

Any help appreciated

Matt
 

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