Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
13
Erster Beitrag:
vor 4 Jahren, 5 Monaten
Letzter Beitrag:
vor 4 Jahren, 5 Monaten
Beteiligte Autoren:
JP, Danny Lauwers, Al, Jose Antonio Garrido, Arie

[WD18] - Setting window coordinates

Startbeitrag von JP am 17.08.2013 08:12

Hi All,

In a particular process I need to open and then arrange on screen a number of windows. I position the windows using code such as:


MyWindow..X = xcoord
MyWindow..Y = ycoord
MyWindow..Width = xwidth
MyWindow..Height = yheight


However, when doing this in a loop with many windows this takes up some time, relatively speaking, because each property is being set and then applied. I am guessing that behind the scenes the window is being moved 4 times. Is there a way to set all 4 properties first and then allow WinDev to apply the values/move the window?

In another dev tool we have a WITH - ENDWITH construct that allows you to set all properties first and then and only after you exit the WITH - ENDWITH construct are all the propeties applied in one go. Anything like this in WinDev


WITH MyWindow
.X = xcoord
.Y = ycoord
.Width = xwidth
.Height = yheight
WNDWITH


I have checked into the DisplayEnabled property but this has no performance improvement.

Antworten:

Hello JP

All windows can open in a position that is relative to a parent window or to the screen itself. Would it work for you to make the windows always relative to single parent window and then you would only need to adjust the parent window position.

If you allow the users to move the windows around and store the positions and sizes then would that solve the problem as you would no longer have to set the window positions ?

Even if you allow the users to move and save positions in a session, you could always delete their window registry settings to restore the windows to their default positions on startup.

Regards
Al

von Al - am 18.08.2013 04:27
Hi Al,

I have been experimenting with lots of things. The interesting finding is this: if you run the performance profiler and then a routine which opens a number of windows without positioning them you will find they open quite quickly. However, if you try and change the top left corner coordinate X or Y position then this incurs a performance hit. The subsequent setting of the other coordinate (either the Y or the X depending on what you did first) does not incur this same hit! So just the first X or Y setting incurs a performance hit ...

I have searched the help for a function which can move a window and thus set all four coordinates (X,Y,width, height) in one go but have not found anything. Guess it will just have to be one of those things.

von JP - am 19.08.2013 07:30
JP,
when exactly do you set X and Y?
In the opening section of the window or the init-part. I guess the opening part would be the right place.

von Arie - am 19.08.2013 07:54
This could help you: WINSIZE

Moving a window and/or modifying its height and/or width


WinSize([Name of the window] ,[Horizontal Position] , [Vertical Position] , [Width] , [Height])


Lookup details in the help

Danny

von Danny Lauwers - am 19.08.2013 08:13
Hi Arie,

Tried in openeing section and the init. The same performance impact, no difference.

Thanks for replying.

von JP - am 19.08.2013 11:01
Hi Danny,

I just tried this function and it has no performance improvement. It is the same as seting x,y,width,height individually. It seems that the first postioning instruction (whether setting X or Y) incurs a performance hit but thereafter setting the other 3 coordinates has minimal impact. Interesting.

Anyway, thanks for replying.

von JP - am 19.08.2013 11:03
Hello Danny

Just guessing, but it looks like the first change in the co-ordinate triggers a load of the windows into memory, which takes the time and then Windev has to adjust all the dependant co-ordinates, but after that it is all performed in memory.

A couple of thoughts re the saving of window positions:

If you have it on, then turn it off otherwise the windows are being positioned twice, once by the registry settings and then again by you.

On the other hand, if you are using the window position save option would it be possible to write the window positions into the registry or ini file where they are saved ? The details are in French but a little trial and error with before and after values may tell you how the window positions are stored and that may be quicker than you issuing commands..

Another thought is, does it help if the windows are invisible when the co-ordinates are being applied and then all made visible when the positioning is done - this process may make it seem quicker to the user as they would not see the windows load sequentially.

Regards
Al

von Al - am 19.08.2013 12:51
Ni. Just for curiosity, how much peromance hit are you talking about?

Retardas,
jose Antonio.

von Jose Antonio Garrido - am 19.08.2013 14:25
Hi Jose,

This is a good question. Although the time to open and position say 20 windows is just a second or two this will be a (relatively small) issue for us because by comparison other langauges we use can do this in half the time or even less. Some of our users create workspaces/desktops with 100 windows in a tabbed spreadsheet type environment. This will take perhaps 30 seconds to open and re-create compared to perhaps 10 seconds currently.

So on the one hand it does not sound like a big deal but you know users :) They will compare to other solutions we have provided and wonder why the new WinDev version does this slower even if that "slower" is relatively fast considering what is all being done.

Anyway, it was one of those visual things that we noticed and had to investigate to find the cause and see if there was a faster way than setting the coordinates manually.

von JP - am 19.08.2013 14:51
Hi Al,

Yes we have investigated these options. We start the window as invisble and then position it, update its contents and then make it visible. This is the fastest it can get. We are not storing the windows position using WinDev built in options (registry or xml). we are storing the window positions ourselves as we also store various other information about the window and it's contents at the same time.

You are correct that the first positioning of the window is causing WinDev to consume some time/resources to do "something" with the window. Once that "something" is done then subsequent re-positioning of the window is very fast by comparison.

If you open a sequence of windows and do not change X or Y then the windows open probably twice as fast vs. changing the X or Y once open.

Thanks for your input into this investigation.

von JP - am 19.08.2013 14:55
Hi.

Did you tried to write the window position in registry, just before opening them, and then let WD open the window at the previusly specified coordinates using the bult.in window position save option.

It's one of the things that Al suggested, but it was not clear to me if you already tried, and I really think it's a good idea.
To check it out simple enable the "save window position" option, then open 100 windows, then organize them as you like, then close the application, then run the application, open the application, and open the 100 windows. WD will open them at the correct position.

If you see any speed improvement then you will have to see how is the information stored in registry. I once saw it and it was very easy to find, Something like HKLM OR HKCU/WINDEV/APPNAME/WINDOW NAME but i'm not sure since i'm writing on a tablet now.

Regards,
Jose Antonio.

von Jose Antonio Garrido - am 19.08.2013 22:42
Hi,

Maybe giving the coordinates with the OPEN or OPENCHILD function is faster ?

OpenChild("WIN_EditWindow, 10, 500")

I don't think that the height and width can also be set with this function.

It's worth a try ?

Danny

von Danny Lauwers - am 20.08.2013 06:58
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.