Home › Forums › Konopka Signature VCL Controls (formerly Raize Components) › FormState
- This topic has 7 replies, 2 voices, and was last updated 2021-11-30 at 12:20 am by Barry Wood.
-
AuthorPosts
-
-
May 27, 2020 at 10:37 am #1861
Hi,
Just noticed that the Main form on my project is not getting it’s position/size saved using the FormState component. It is working OK for all my other forms but not the main form.
I can look at the INI file and it doesn’t get updated after I move, then close the application.
It works fine on other projects. And I’ve deleted the component and put a new one on.
Any thoughts?
-
May 27, 2020 at 4:36 pm #1863
Did the Enabled property of the TRzFormState component on your main form get set to False? I assume that the RegIniFile property is set to an instance of TRzRegIniFile–otherwise, you would get message boxes displaying when you start and stop your app. Did you change any properties of the TRzRegIniFile component?
Ray
-
June 27, 2020 at 10:41 am #1975
Ray,
Enabled is set to True, FormState works on all other forms in project but this one.
What I did was add this:[MAINFORM]
Maximized=0
Left=824
Top=209
Right=1272
Bottom=880
Saved=1… to the Ini file, and the Main form does obey these positions, so it is reading the INI file on start up. It also writes new values to the INI file as I move the forms about. All except the Main form, though. I can move the Main form about and exit and the time on the INI file doesn’t change.
Because it is the Main form, and just a starting place to do other things, I’ve set the Window Position to poDeskTopCenter, so this issue doesn’t really affect me now (and hopefully not my Users of this app either). Just a curious thing. I was going to rebuild the Main form from scratch, checking the position of the new form was saved correctly but not sure the extra work doing this is worth while.
I’ll wait until I’ve migrated it to 10.4 and see if that makes any difference.
-
July 1, 2020 at 12:08 am #2069
Hi Barry,
Does your main form do anything with the OnClose event? The TRzFormState component hooks into the OnCreate, OnShow, and OnClose events in order to load and save the form position. Given that the component is reading the “saved” position values properly, I suspect that something is interfering with the actual save process.
Ray
-
July 1, 2020 at 2:51 am #2072
Hi Ray,
From this form there is no code in the OnClose or OnShow events, but I have the following code in the OnCreate event:
Procedure TfMain.FormCreate(Sender: TObject);
var
cStyle: String;
begin
lb.Height:= 100; lb.Width:= 300;
lb.Items.AddStrings( TStyleManager.StyleNames );
//get last used Style from INI file …
cStyle:= INI.ReadString(‘STYLE’, ‘LastUsedStyle’, ‘Windows10’);
TStyleManager.SetStyle( cStyle );
end;I commented this code out and tried again, but no change. The read is done, but it doesn’t write back any changed position. This is in 10.4 as well, so no ‘fix’ there.
When I’ve time I’ll re-create this mainform ensuring the formstate is saved during the process, then replace the existing main form. It’s another of those ‘Delphi things’ I think, not major just an annoyance. Certain it’s nothing to do with your component, but thanks for thinking about what it could be.
-
July 4, 2020 at 5:34 am #2080
Ray,
Something interesting. I removed your FormState component from the Main form and added some INI code, which reads and writes to the INI file. Tracing through debug all 4 positions were read correctly, and assigned to the correct properties on the form. When closing, the correct form positions are written back to the INI file – so all that seems to work as it should.
However, what happens when I open the application now is that the Top and Left values are ignored but the height and width properties are used! Top and Left always revert (on my screen) to 52 and 52, no matter what the values are in the INI file.
As a point of maybe interest, in the Forms setting this is the only visual form that is auto-created (I also auto-create a data-module and some report forms). Could that have a bearing I wonder.
-
July 7, 2020 at 12:45 am #2085
I wonder if it related to some other property setting that you have changed on the form. Such as Position. Would it be possible to have you send me the DFM file for your main form? If so, send it to our support email address and I’ll take a look.
Ray
-
November 30, 2021 at 12:20 am #1888
Hi Ray,
Here are settings for both FormState & Ini components:
So all I ever do with this setup is connect the FormState to the INI file and give the Section a unique name. I’ve done the exact same on many other forms and they all work. Most of the other forms in my project connect their own FormState components to the INI file in this main form and work correctly.
This sounds like another one of those oddities in 10.3, like I’ve ‘unearthed’ before, that work fine in some projects and not in others, with no discernable difference (like the VersionInfo, or retaining the Language settings). I only hope 10.4 has addressed these issues.
-
-
AuthorPosts
- You must be logged in to reply to this topic.