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.
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!