Advanced
Lesson 3: Opening XFT Forms in XMetaL
Calling
XFT forms in XMetaL Author
There are two
ways to launch a form from your customization:
- Create a macro
- Use the
Advanced Display properties for an
element
In this
tutorial we will look at the Author form created in the last tutorial as part
of the sample Journalist customization, then create a very simple form and call
it first from a macro, then as mapped content.
This lesson
will take about 20 minutes to complete.
View
the new Author form
To see the
Author form created in the last tutorial:
- Open
XMetaL Author.
- Click
File >
New. Click the
Journalist tab and select
Article.
- A new document
opens, based on the Journalist
customization. Select the Tags On
view and place the cursor after the closing
/Title
tag.
- If it is not
already visible, show the Element
List: Click View >
Element List.
- In the
Element List, select
Author
and then click Apply.
The
Author form you created in the last
tutorial opens. You can enter data and save the document, or just close the
document.
Create
a new form to be mapped
We will now
quickly create a form to be added to the Mini-Journalist customization.
- Close
XMetaL Author, and open
XMetaL Developer.
- In
VS.NET, click
File menu, click
Open, then click
Project. Select
MiniJournalist.sln
in the \{install
path}\Blast Radius\XMetaL 4.5\Developer\Samples\MiniJournalist folder.
- If it is not
already visible, show the Solution
Explorer: Click View >
Solution Explorer.
- Right-click the
MiniJournalist customization in the
Solution Explorer, click
Add >
Add New Item.
- Enter the name
Chapter in the
Name field. From the items available
in the dialog, select XFT Form (any
language). The item will be added to the project.
- Double-click the
Chapter.xft form in the
Solution Explorer. The
XMetaL Form Layout Editor opens.
- Add a single Label
with the caption "Chapter name" and add a single Edit box.
- For the
XPath property of the Edit box, enter
the path to the
chapter
element:
./chapter
- Save the form.
Create
a macro to call the form
Now that we
have a very simple form, we want to view the methods for calling it from XMetaL
Author. The first method we will look at is calling it from a script
(macro).
To call the
chapter form from a script:
- If you closed
XMetaL Developer after the last step,
start it again.
- If it is not
already visible, show the Solution
Explorer: Click View >
Solution Explorer.
- In
VS.NET, click
File >
Open >
Project. Select
MiniJournalist.sln
in the \{install
path}\Blast Radius\XMetaL 4.5\Developer\Samples\MiniJournalist folder.
- Right-click the
Project in the Solution Explorer,
click Add >
Add New Item.
- In the
Name field, enter
CallChapterForm,
and select New Script File.
- In the dialog box
that opens, specify the following:
- Jscript
- XMetaL Author only
- For
Name,
Call
Chapter Form
- For macro
file, Journalist.mcr.
- Click
Finish.
- From the
Solution Explorer, double-click the
new CallChapterForm.js script, and
add the following code:
var
dlg=Application.CreateFormDlg("C:\\Program Files\\Blast Radius\\XMetaL
4.5\\Developer\\Samples\\MiniJournalist\\chapter.xft");
dlg.DoModal();
dlg=null;
- Save the script
and debug the project, answering Yes
to building.
- Once
XMetaL Author starts, open a document
based on the MiniJournalist
customization (for example, SimpleGuide.xml).
- Click
Tools >
Macros. You will see the
Call Chapter Form macro listed in the
dialog that appears. Select it and click Run.
Your XFT form
appears.
- Close
XMetaL Author.
You can also
use other customization techniques to call the script (other than using the
Macros dialog box). For example, you
can use one of the event macros, or you can create a custom toolbar with a
button that runs the script.
Call
the form automatically from XMetaL Author
Another method
to call the XFT form is to modify an element's
Advanced Display properties so that
the form is displayed when the cursor is in the element.
To set the
Advanced Display property for the
chapter
element:
- If you closed
XMetaL Developer after the last step,
start it again.
- If it is not
already visible, show the Solution
Explorer: Click View >
Solution Explorer.
- In
VS.NET, click
File >
Open >
Project. Select
MiniJournalist.sln
in the \{install
path}\Blast Radius\XMetaL 4.5\Developer\Samples\MiniJournalist folder.
- Double-click the
Journalist.ctm
file to open the list of elements and their customization properties.
- If it is not
already visible, show the Properties
Window: Click View >
Properties Window.
- Click the
chapter
element in the content window. The Properties Window changes to show the
properties for the selected element.
- Click the button
beside the Advanced Display property,
and, in the dialog box that appears, click XFT Form, then run the
XFT Setup Wizard by clicking the
Setup button. Specify the following:
- Embedded
- Replace Content
- To
Always display the form
- Save and debug
your project, answering Yes to
building.
- Once
XMetaL Author starts, open a document
based on the MiniJournalist
customization (for example, SimpleGuide.xml).
- Place the cursor
inside a
chapter
element. Your form automatically appears.
Continue with the next lesson: Designing a
Container Application for XMetaL 4.5...
Last modified: Friday, May 21, 2004 3:59:22 PM