Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] Application Menu bar disappears when used OLEControlSite

Hi,

I have a requirement to open word 2007 document with content controls in it in SWT. I have used org.eclipse.swt.ole.win32 classes for this.

I have followed following procedure to open a document

1.       Created a new view in my application extending from ViewPart

2.       In createPartControl method , I have created a OleFrame in the parent composite. Added File and Windows menu on the frame.

        oleFrame = new OleFrame( parent, SWT.NULL );

        oleFrame.setBackground( JFaceColors.getBannerBackground( oleFrame.getDisplay() ) );

        IMenuManager fileMenu = AIFUtility.getWorkbenchWindowMenuManager().findMenuUsingPath( IWorkbenchActionConstants.M_FILE );

        oleFrame.setFileMenus( new MenuItem[] {((MenuManager)fileMenu).getMenu().getParentItem() } );

        IMenuManager windowsMenu = AIFUtility.getWorkbenchWindowMenuManager().findMenuUsingPath(       IWorkbenchActionConstants.M_WINDOW );

        oleFrame.setWindowMenus( new MenuItem[] {((MenuManager)windowsMenu).getMenu().getParentItem() } );

  

3.       Created a file

File file = new File("D:\\Demo\\ContentControl.docx");

4.       Created a new ControlSite

  OleControlSite  oleControlSite = new OleControlSite( oleFrame, SWT.NONE, file);

5.       Activated a control site

oleControlSite.doVerb( OLE.OLEIVERB_SHOW );

 

After this new View open is opened and my application menu bar displays only File and Windows Menus (as set in step 2)

6.       When I close the view I am performing oleControlSite.deactivateInPlaceClient();  and disposing the oleFrame

7.       Once dispose Menu Bar disappears from the application.

8.       Same thing when I do with the OleClientSite instead of OleControlSite, thing works fine and applications old menu bar (with File,Edit,View,Window,Help menus) is restored when new view created by me is closed.

 

I need to use OleControlSite as I have to take advantage of events for content control listeners, which I believe I can do only if I use OleControlSite.

 

Any help in this regard is appreciated.

 

 

Thanks and Regards,

Mahesh


Back to the top