Turn off my blog sidebar--word 2007 advanced Application 7

Source: Internet
Author: User

Turn off my blog sidebar--word 2007 advanced Applications (vii)

The implementation of my blogs button has the following main requirements:

When Word 2007 starts, the "my Blog" sidebar is loaded but not displayed.

When my blogs button is pressed, the My blog sidebar is displayed, and the My blog sidebar is hidden when my blogs button is released.

The only way to display the My blog sidebar is through the My blogs button, but there are two ways to hide it: Through the My blogs button or the X button in its upper-right corner. Regardless of how the user hides the "my blog" sidebar in that way, we must ensure that my blogs is in the correct state.

First, we revise the code in ThisAddIn.cs and remove the statement in the ThisAddIn_Startup () method that shows the "My Blog" sidebar (that is, set its Visible property to True):

  

Next, go back to the Bloggingribbon designer and add event Handler for my blogs Click event:

  

When we create a word add-in project, Visual Studio 2008 Beta 2 automatically creates a globals class for you, and you can access instances of Plug-ins through the ThisAddIn properties of the class. There is a customtaskpanes attribute in the ThisAddIn class, the type is CustomTaskPaneCollection, which contains the CustomTaskPane we added, including the "My Blog" sidebar. In this way, we can select the "My Blog" sidebar in the CustomTaskPanes and synchronize the value of the checked property of my blogs button to its Visible property to control its display and concealment. It is worth reminding that I am here to assume that only the value of the title attribute of the "my Blog" sidebar is my Blogs.

When the user clicks the X button in the upper right corner of the "my Blog" sidebar to close it, we need to synchronize the status of my blogs button correctly, which can be done by handling the visiblechanged event of the "My Blog" sidebar:

  

It is worth reminding that Visual Studio 2008 Beta 2 sets its access modifier to internal when creating the variable tgbmyblogs for my blogs button, so we can modify it directly in the ThisAddIn class. Alternatively, you can #01的m_MyBlogsPane的访问修饰符改为internal the code so that you can #02中对Globals the code. THISADDIN.M_ The Myblogspane.visible property is directly modified without the need for a lookup.

Now, let's take a look at the effect of the operation:

  

Figure

The next article will introduce you to add/Remove blog information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.