RibbonX for Dummies: Chapter 6 (Part 2) (
Page 3 of 6 )
Selecting a form
The user's first task is selecting a form. Because the user could have multiple
forms in progress at any given time, the application closes only the current
document if it's obvious that the user has opened Word for this specific document.
Consequently, the user will have to close any documents that aren't
needed for a particular session.
Understanding differences between Content
Controls and Legacy Controls
Anyone who worked with forms in older versions
of Office knows about the controls that
Microsoft provides for creating forms. You
simply add the controls you want to the page,
configure them, and then add some VBA code
as needed to perform required tasks in the
background. It's still possible to use these controls
in Office 2007, but you must look for them in
a different location. The controls that you're
used to working with appear on the Developer
tab in the Controls group in a small button called
Legacy Controls. When you click this button,
you'll see a small window containing two areas:
Legacy Forms and ActiveX Controls. To use a
control, simply place the cursor where you want
the control to appear on the form and then click
on the control as you normally would.
Microsoft also makes it possible to add new
ActiveX controls. For example, the form in the
"Filling Out Forms" section of the chapter
includes a Calendar control. To add this control
to your form, click the More Controls button that
appears at the end of the list in the ActiveX
Controls section. You'll see the More Controls
dialog box, where you can choose the Calendar
Control 12.0 entry and click OK. Adding the
Calendar control to your form doesn't add it to
the ActiveX Controls list, so you must perform
this action every time you want to use the special
control.
Content Controls are new to Office 2007 and
Microsoft has given them a prominent location in
the Controls Group. These controls don't work like
the form controls you used in the past. In fact,
these controls are part of a new technology
called Building Blocks that you can read about at
http://blogs.msdn.com/microsoft
_office_word/archive/2006/11/21/
building-blocks-part-i.aspx
You can read more about how Building Blocks
and Custom Controls work together at
http://blogs.msdn.com/microsoft_
office_word/archive/2006/11/22/
inserting-and-swapping-buildingblocks.
aspx
You can even create your own Building Blocks
using information from the article at
http://blogs.msdn.com/microsoft
_office_word/archive/2007/01/03
/creating-building-blocks.aspx
The special editor found at
http://www.codeplex.com/Wiki/
View.aspx?ProjectName=dbe
helps you manage and work with Custom
Controls. Because this topic is so complex and
is outside the scope of this book, you won't see
any further references to either Building Blocks
or Custom Controls in this book.
Creating the physical presentation
The user sees the gallery control when choosing a form. However, you don't
provide any content for this control at design time. That's because you can't
predict which forms the user's machine will contain. All content appears at
runtime. Consequently, the XML for this example contains a lot of callbacks,
as shown in Listing 6-11.
Listing 6-11: Defining the Gallery Content
<gallery id="FormList"
label="Available Forms"
imageMso="BusinessFormWizard"
size="large"
columns="2" rows="2"
itemHeight="100" itemWidth="180"
getItemCount="GetItemCount"
getItemID="GetItemID"
getItemImage="GetItemImage"
getItemLabel="GetItemLabel"
onAction="ItemClicked"/>
You do need to consider a few configuration issues when creating the
<gallery> element. Notice how the code uses the columns and rows
attributes to control the number of templates the user sees at any time. You
need to provide some amount of control or the gallery could very well fill the
screen, making a selection more difficult, rather than easier.
It's also important to control the item size. Otherwise Word displays each of the
templates at the full size you used to capture the image. You may have to spend
some time figuring out the right size for the image. The user has to see what the
form looks like, but you don't want the form full-size either. Maintaining the
aspect ratio also helps in the recognition process. For example, if the screenshot
height is 500 and the width is 900, and you reduce the height to 100 for display
purposes, then you should set the itemWidth attribute to 180.