save size position after showFormInDialog()

How can i save the last position/size of showFormInDialog(), after the user resized/moved arround the modal window.

I tried in a closebutton of the form:

var cWn='myWindowName'
globals.cWinDims=
   application.getWindowX(cWn) + ',' +
   application.getWindowY(cWn) + ',' +
   application.getWindowWidth(cWn) + ',' +			
   application.getWindowHeight(cWn)
	
application.closeForm()

but i always get “0,0,0,0”

Thanke you for help

Hi Alessandro,

take a look at this thread, especially the last 3 posts: http://forum.servoy.com/viewtopic.php?f=8&t=13954

Thanke you Marc. I read this tread careful, gave the window an own name, but it still doesnt work.
What i did in detail:
Show the form

application.showFormInDialog(
	'ProzedBrowSelect',
	aFrmDims[0],aFrmDims[1],aFrmDims[2],aFrmDims[3],
	'My Test text...',
	true, null, [b]'Test1'[/b], true)

In a close button (in first column of a row, for “select the line” and “close the window”) i call the code:

globals.cWinDims = application.getWindowX('Test1') + ',' +
			application.getWindowY('Test1') + ',' +
			application.getWindowWidth('Test1') + ',' +			
			application.getWindowHeight('Test1')
	
application.closeForm('Test1')

Interesting: Also the
application.closeForm(‘Test1’)
or
application.closeForm(‘ProzedBrowSelect’)
doesen’t work !
But Servoy help says: //application.closeForm(‘windowOrDialogName’); //closes the dialog/window with this specific name

And, back to my beginning question: Why the globals.cWinDims still shows “0,0,0,0”

Thanke you for any help

Which version of Servoy do you use, and is this smart- or webclient?

mboegem:
Which version of Servoy do you use, and is this smart- or webclient?

5.2.2 - build 1002
smart client
regards

stefanoni:

application.showFormInDialog(ProzedBrowSelect',
aFrmDims[0],aFrmDims[1],aFrmDims[2],aFrmDims[3],
'My Test text...',
true, null, [b]'Test1'[/b], true)


In a close button (in first column of a row, for "select the line" and "close the window") i call the code:


globals.cWinDims = application.getWindowX(‘Test1’) + ‘,’ +
application.getWindowY(‘Test1’) + ‘,’ +
application.getWindowWidth(‘Test1’) + ‘,’ +
application.getWindowHeight(‘Test1’)

application.closeForm(‘Test1’)



Interesting: Also the 
**application.closeForm('Test1')** or **application.closeForm('ProzedBrowSelect')** doesen't work !
But Servoy help says: *//application.closeForm('windowOrDialogName'); //closes the dialog/window with this specific name*
And, back to my beginning question: Why the globals.cWinDims still shows "0,0,0,0"

I cleared up the mystery :

The chain of problems starts with a simple thing called “integer or string” :oops: :

My position- and size-parameters ( aFrmDims[0 to 3] ) valued the numbers as strings instead of integers.
That’s it ! (Just read read further if you are interested in details)

The Parameters as strings instead of numbers makes Servoy show the form with the default parameters:

  • for example, the dialogTitle shows the default (in my case ‘ProzedBrowSelect’ insted of ‘My Test text…’).
  • The window is not accessible any more by the windowName.
  • The size and position start with default (second and next shows the same size and position then first)
  • application.getWindowX / Y returns zero
  • application.getWindowWidth / Height returns zero

So you like to save size/position of the form and the fields of a form with tableview(locked)

  • simply showFormInDialog() with numeric coordinates and unique windowName (each call)
  • in the closebutton or hide(): store the actual (moved or resized) position of the fields with
var oBlueFrm = solutionModel.getForm('ProzedSuch')
oAktEles = forms.ProzedSuch.elements
var nAnz = oAktEles.length
var cFldNam
for ( var i=0; i<nAnz; i++ ){
	oBlueCmpnent = oBlueFrm.getComponent(oAktEles[i].getName())
	oBlueCmpnent.width = oAktEles[i].getWidth()
	oBlueCmpnent.x = oAktEles[i].getLocationX()
}
forms.ProzedSuch.controller.recreateUI()

then store the the coordinates of the window:

application.getWindowX( 'uniqueWindowName' ) (also getWindowY() getWindowWidth() getWindowHeight())

then close the form (no windowname necessary)

If you like to format the fields a bit before you close and store:

just make a rightclick function on the fields wich just works in developer:

var cAktFldNam = event.getElementName()
var oBlueFld = oBlueFrm.getComponent(cAktFldNam)
var cAntw = plugins.dialogs.showSelectDialog('Field '+cAktFldNam',null,'1=CENTER','2=LEFT','3=RIGHT','4=BOLD','5=NORMAL','6=Font Chooser')
cAntw = cAntw.substr(0,1)
switch (true) {
	case cAntw == '1':
	oBlueFld.horizontalAlignment = SM_ALIGNMENT.CENTER
	break;
	case cAntw == '2':
	oBlueFld.horizontalAlignment = SM_ALIGNMENT.LEFT
	break;
	case cAntw == '3':
	oBlueFld.horizontalAlignment = SM_ALIGNMENT.RIGHT
	break;
	case cAntw == '4':
	oBlueFld.fontType = 'Verdana,bold,11'
	break;
	case cAntw == '5':
	oBlueFld.fontType = 'Verdana,plain,11'
	break;
	case cAntw == '6':
	if(!oBlueFld.fontType){
		cX='Verdana,plain,11'
	}else{
		cX=oBlueFld.fontType
	}
	oBlueFld.fontType = application.showFontChooser(cX)
	break;

	default:
	break;
}
// show new things in the actual form 
forms.ProzedSuch.controller.recreateUI()

Greetings from a quit happy hacker