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:
  1. Create a macro
  2. 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:
  1. Open XMetaL Author.
  2. Click File > New. Click the Journalist tab and select Article.
  3. A new document opens, based on the Journalist customization. Select the Tags On view and place the cursor after the closing /Title tag.
  4. If it is not already visible, show the Element List: Click View > Element List.
  5. 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.
  1. Close XMetaL Author, and open XMetaL Developer.
  2. 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.
  3. If it is not already visible, show the Solution Explorer: Click View > Solution Explorer.
  4. Right-click the MiniJournalist customization in the Solution Explorer, click Add > Add New Item.
  5. 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.
  6. Double-click the Chapter.xft form in the Solution Explorer. The XMetaL Form Layout Editor opens.
  7. Add a single Label with the caption "Chapter name" and add a single Edit box.
  8. For the XPath property of the Edit box, enter the path to the chapter element: ./chapter
  9. 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:
  1. If you closed XMetaL Developer after the last step, start it again.
  2. If it is not already visible, show the Solution Explorer: Click View > Solution Explorer.
  3. In VS.NET, click File > Open > Project. Select MiniJournalist.sln in the \{install path}\Blast Radius\XMetaL 4.5\Developer\Samples\MiniJournalist folder.
  4. Right-click the Project in the Solution Explorer, click Add > Add New Item.
  5. In the Name field, enter CallChapterForm, and select New Script File.
  6. In the dialog box that opens, specify the following:
    1. Jscript
    2. XMetaL Author only
    3. For Name, Call Chapter Form
    4. For macro file, Journalist.mcr.
  7. Click Finish.
  8. 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;
  9. Save the script and debug the project, answering Yes to building.
  10. Once XMetaL Author starts, open a document based on the MiniJournalist customization (for example, SimpleGuide.xml).
  11. 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.
  12. 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:
  1. If you closed XMetaL Developer after the last step, start it again.
  2. If it is not already visible, show the Solution Explorer: Click View > Solution Explorer.
  3. In VS.NET, click File > Open > Project. Select MiniJournalist.sln in the \{install path}\Blast Radius\XMetaL 4.5\Developer\Samples\MiniJournalist folder.
  4. Double-click the Journalist.ctm file to open the list of elements and their customization properties.
  5. If it is not already visible, show the Properties Window: Click View > Properties Window.
  6. Click the chapter element in the content window. The Properties Window changes to show the properties for the selected element.
  7. 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:
    1. Embedded
    2. Replace Content
    3. To Always display the form
  8. Save and debug your project, answering Yes to building.
  9. Once XMetaL Author starts, open a document based on the MiniJournalist customization (for example, SimpleGuide.xml).
  10. 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