Welcome! Log In Create A New Profile

Advanced

[WD23] How to store window size and position?

Posted by Ola 
Ola
[WD23] How to store window size and position?
January 29, 2021 12:34PM
Hi all

Practically all my windows have the "resizable" and "Store the size and position" checkboxes checked. Well, the "Resizable"-setting works, but the "Store the size and position"-setting does not. Some windows open in their default design size, while some open in maximum size, alway the same even after resizing the window and re-opening again! So what's up? Is there some trick to make it work? I am testing in Windows 7 home edition.

Best regards
Ola
Ola
Re: [WD23] How to store window size and position?
February 04, 2021 05:56PM
Am I really the only one having this problem, or paying attention to it? Any suggestions for resolving this? Maybe some cleaning of the Windows registry is needed? What kind?

Ola
Erik Schwarz
Re: [WD23] How to store window size and position?
February 08, 2021 04:22PM
Hi Ola,

have seen this with my app, too. Unfortunately I can't say why it happens sometimes.
My feeling says,that it may happen with 'old' windows as since a few years I didn't had have that problem again with new windows.
If I remember, but I'm not sure, one of that windows I had repaired by uncheck the option - change something in that window - repair and recompile, then check the option again, or doing something like this. Using WD22 that time.
Hope this can help you.

G

Erik
Re: [WD23] How to store window size and position?
February 08, 2021 04:56PM
Hi Ola,

instead of letting WinDev store some control parameters in the registry, I let a HFSQL file do it. Since it is a multiuser program, the parameters are stored for the current user only. So, one user may have the rows of a Table in green and in Arial 14, the other in blue and in Verdana 11. You could do much the same by storing the window's x & y sizes and its position within the screen. Maybe, you could put a small button the window to give the ability to store these parameters. And you could put reading / positioning the window's parameters into .. after initialization.

However, if you don't want to mess with single windows all over your screen then you could use MDI with maximized MDI-windows or (much harder to accomplish) internal windows,

Kind regards,
Guenter Predl
office@windev.at
Ola
Re: [WD23] How to store window size and position?
February 08, 2021 04:59PM
Hi Erik,

Thanks for your response. These are all more or less old windows that have gone through several WD updates. And yes, sometime earlier I did not have this problem, I just don't remember when. But sometimes this just seems so hopeless; if you fix something, soon there will be some new problems out of the blue.

Best regards
Ola
Re: [WD23] How to store window size and position?
February 08, 2021 06:11PM
Hi Ola

I believe (but may be wrong) that in older versions of WD (maybe still today, haven't looked) the sizing options in the 7 tabls of teh window description provided an option to always open a window at it's initial size... Maybe that flag still plays a role in your case.

Cheers

Peter
Re: [WD23] How to store window size and position?
February 08, 2021 11:18PM
Hi Ola,

Have a look at InitParameter.
Perhaps changing he storage to file instead of registry will fix things.
Registry may be messed up over the years and a file can easily be deleted.

Kind regards,
Piet
Ola
Re: [WD23] How to store window size and position?
March 08, 2021 02:34PM
Hi All,

Thank you all for your help.

According to Piet's advise I added this code line to the global declarations
of the app:

InitParameter(ParamXML,"WindowSettings.XML")

This does create the specified XML file, and saves a lot of data of the
windows that were changed during the the last session, saving and
restoring any changes made in table columns in a window, but the
sizing and positioning of the window is not restored
.
The changed windows open in their default design size.
Should I add some additional code? Where?

Also, I wonder how effective it is to use an XML file for this, as the most
of the file contents are just starting and ending labels for very small pieces
of data, typically some 50-60 characters of label text for just one character
of actual data! An XML file holding the data of just one window is some 18
kilobytes in size and I have hundreds of windows in the app.
Ini file might be more effective, but I understand it has some serious size
limitations

Best regards
Ola
Re: [WD23] How to store window size and position?
March 09, 2021 09:43AM
Hi Ola,
Just have in mind the following when you use an XML file instead of the registry:

(1) They get "destroyed" a lot - almost all the time if a computer does NOT have a UPS.
So a good idea would be to handle this problem in an exception, like:

sParameterFile is string = "..." // your parameter file
WHEN EXCEPTION IN
InitParameter(paramXML, sParameterFile)
DO
IF fFileExist(sParameterFile) = True THEN fDelete(sParameterFile,frReadOnly+frToRecycleBin)
InitParameter(paramXML, sParameterFile)
END

(2) They are slower than the registry - especially when you close a window with many tables etc or you are working with dynamic tabs ..
(3) At least in WD25 you will often see "erratic" behavior on your anchored controls.
The only solution is to delete the XML file frequently - but users don't like it because they lose all their settings ...

Regards
Steven Sitas
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: