Pages: 1
Print
Author Topic: How to show XFT non-modal  (Read 252 times)
spyro
Member

Posts: 35


« on: July 19, 2011, 09:16:11 AM »

Hello,

how can I show a XMetaL form non-modal (the XMetaL mainwindow is still alive, scrolling possible etc.)?

I only can find this method:

Set dlg=Application.CreateFormDlg(application.Path & "\StartUp\xpath.xft")
dlg.DoModal()
dlg=Null


which freezes the main window.

(XMetaL 5.5)

Thank you,
spyro
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 1546



WWW
« Reply #1 on: July 22, 2011, 05:15:38 PM »

You can try this undocumented and currently unsupported solution:

Code: (JScript example)
var XftCtrl = new ActiveXObject("XF.XFTForm");
var formPath = Application.Path + "\\Forms\\myform.xft";
/*following line tries to kill the form if it is launched
   a second time, however, the JScript engine decides
   when this cleanup actually occurs*/
nonmodalDlg = null;
nonmodalDlg = XftCtrl.StartForm(formPath, 0);
XftCtrl = null;

You have to be careful with the code you run inside a dialog launched this way. Most XFT forms ultimately make a change to the current document when the user dismisses them. Depending on what your dialog does you may need to take into account the fact that the user may be able to perform some or all of the following actions after launching and while interacting with your form:
    1) Close the current document.
    2) Switch to or open another document.
    3) View the current document using another view (of the 4 available).
    4) Change the selection in the current document.
    5) Delete the current selection.
    6) Cut or copy the current selection or paste over it.
    7) Add additional markup or text into or around the current selection.
    8) Run a macro.
    9) Launch another XFT form.
    10) Open and interact with other portions of the XMetaL Author application (Attribute Inspector, Element List, Spell Checker, etc).

Depending on what your form does this might add an order of complexity to any code you write in order to catch every possible scenario a user might perform that would break your code. Also depending on what your form needs to do it might not make sense to allow the user to run it this way.
« Last Edit: July 22, 2011, 05:19:10 PM by Derek Read » Logged
spyro
Member

Posts: 35


« Reply #2 on: July 25, 2011, 03:23:36 AM »

Hello Derek Read,

thanks for your quick reply.

I had to change your code in the following VBS syntax for my project:

      
Code:
set XftCtrl = CreateObject("XF.XFTForm")
formpath = application.Path & "\StartUp\xpath.xft"
set nonmodalDlg = nothing
set nonmodalDlg = XftCtrl.StartForm(formpath, 0)
Set XftCtrl = nothing

It doesn't throw an error and seems to work in the way that it opens the xft. But once  the form is loaded it is closed immediately.

spyro
« Last Edit: July 26, 2011, 02:25:23 AM by spyro » Logged
Pages: 1
Print
Jump to:  

email us