getFormWidth() not Working?

Version: 5.1.0 - build 956

I have an existing form (shows up in the solution panel and has ‘width’ set to 320) of which I am attempting to get the width dynamically, but the returned value is always zero. I tried referencing the form two different ways using a form method:

function showForm()
{
    var formWidth = forms[ 'frm_arm' ].controller.getFormWidth()

    plugins.dialogs.showInfoDialog( 'DEBUG', 'Form Width: ' + formWidth, 'OK' )
}
function showForm()
{
    var formWidth = forms.frm_arm.controller.getFormWidth()

    plugins.dialogs.showInfoDialog( 'DEBUG', 'Form Width: ' + formWidth, 'OK' )
}

Am I doing something wrong?

I restarted Servoy Developer and the Sybase SQLAnywhere dabase engine, but it did not make any difference.

Thanks!

i tried this as an onshow event on a form:

function onShow(firstShow, event) {
	application.output(controller.getFormWidth());
}

and that prints out the actual width fine in the smartclient

are you trying this in a smart of webclient?
Because webclient will not know the size just yet in onshow.

Hi, Johan.

I copied your code and put it in the onShow event of my form, and it did not work. I came to realize that my form was not being actively displayed, so I added:

application.showForm( 'frm_arm' )

to my code, and it reported the correct form width. So, this is telling me that .getFormWidth() only works with the currently displayed form…not exactly what I was hoping. It seems to me that I should be able to access any form’s properties at any time, not just when they are displayed.

Here is what I am trying to accomplish:

Using the SolutionModel, I want to modify a form prior to showing it in a dialog using:

application.showFormInDialog( 'frm_arm' )

I need to know the form width to add and position objects on the form.

Experimenting further, I found that if I first show my form in a dialog, then issue .getFormWidth(), I get the proper return value. My only concern is adding objects to the form and positioning them while the form is displayed may be visible to our users. I would still prefer to modify the form before displaying it.

Thanks for your quick response and tip…it got me going again!

Using the solution model you can get the designed width of the form already.

Paul

Thanks, Paul. I researched the soloutionModel and found it…definitely a better way to go!