Creating my own "Save current position and size of the window" procedure

Hi,

I want to create my own “Save current position and size of the window” procedure, based on the Open Form Window command
The main reason for this is that when using 4D Volume desktop in a Citrix environment, and working on different PC’s with different resolutions, but connecting to the same citrix client, the standard 4D implementation is not sufficient

Are there other people that have implemented this technique?

1 thing I noticed is the attribute “geometryStamp” in the .json files storing the Window Bounds
Does anybody know what this is? for what is 4D using this attribute?

TIA,
Piotr

this is not really complicated. You need to consider where you store the last position. As record - when it is shared even if Citrix don’t keep the user directory or when the user connects with another machine. But of course this produces issues with different screens. Either your reset the size each time or you need to store a combination of user name/ID with computer name or screen info.

There is one rule to follow: your On load phase needs to be faster than half a second, as faster, as better.
If you modify the window size in On Load AND the on load runs too long, the user will see the screen redraw.
To follow this rule is quite important, as long on load code (in form or objects) produces not only screen redraw issues but also is seen from the end user as slow application, as the window appears frozen.
If you need more to initialize, delay that using Call form, best if several chunks, so the form is active and more and more data appear step by step. Similar as modern OS is booting…

A helper method (quite old, written before dot notation exists in 4D) to read the current window size and store it in an object:


the same to restore the size:

In On Load that could look like:

Tools_SetWindowSizeByObject ($WindowPos)  
$Formname:= Current method name
Tools_AdjustWindowSize ($Formname; Current form table )

After restoring the window position I’ll check if the window is fully visible for the current screen and resize/move if needed. Code here:

But these are just examples, there are many ways to do so.

Hi Thomas,

Thanks for your input, much appreciated
I am going to do something similar as you describe, implementing a technique based on 4D
I am going to store left, top, width, height in a JSON file per Form, as 4D does
The big difference is that I am going to store it in a object attribute with the name of the attribute being the width and height of the screen work area
So, for example :

{
	"w1920h1040": {
		"left": 655,
		"top": 166,
		"width": 880,
		"height": 802
	}
}

With 2 screens connected, I consider this to be another attribute, with the resolutions in the name sperated by an underscore, for example w1920h1040_w1024h790
With this I can store for every combination of connected screens and resoltions the correct bounds of the window
I was curious what the attribute “geometryStamp” is for, but I guess it has to do for determining if the design of the form has changed?

I think you are right. It is possible for the same form to be opened by different dialogs at the same time. A stamp would be useful to make sure that their geometry information don’t cancel out each other.

yes. And just today there was a bug fix showing this:

253195 23/06/2020 ACI0100932 In project mode, form geometry stamp is not reset by the form editor when the object class property is modified

Can I get this geometry stamp by a command?

Hi Thomas,

What I am doing is open the form with the command Open Form Window
As I understand this is recommended by 4D, and not use Open Window
Because Open Form Window does not have a right and top I need to set these with SET WINDOW RECT

$winref:=Open form window($table_ptr->;$form_name;$window_type;$onTheLeft;$atTheTop)
SET WINDOW RECT($window_left;$window_top;$window_right;$window_bottom;$winref)

As you can see I don’t wait for On Load, but do it immediately
Because of this two step action the user sees a kind of flash, i.e. the moving of the window.
This is ugly and can be prevented by calling Open Window
Is there another better way? What is your opinion about this?

Gr,
Piotr

1 Like

What is $onTheLeft, is this the constant “on the left”?

If yes, replace it with $window_left, same for $window_right

It’s perhaps time for 4D to update/upgrade its own system for ALL and NOT that all developpers have to recreate its own same procedure :thinking:

BTW if it could also integrate this feature request it can solve many redevelopment

The context is now use for optimizing ORDA, it can be also interesting to use this concept for manage windows…

OK, you are right, but what about right and bottom?
The window positions on the correct xpos and ypos, but there still is a kind of visual effect because of changing width and height