FormState

Viewing 7 reply threads
  • Author
    Posts
    • #1861
      Barry Wood
      Participant

        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?

      • #1863
        Ray Konopka
        Keymaster

          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

        • #1975
          Barry Wood
          Participant

            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.

          • #2069
            Ray Konopka
            Keymaster

              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

            • #2072
              Barry Wood
              Participant

                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.

                 

                 

              • #2080
                Barry Wood
                Participant

                  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.

                • #2085
                  Ray Konopka
                  Keymaster

                    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

                  • #1888
                    Barry Wood
                    Participant

                      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.

                       

                  Viewing 7 reply threads
                  • You must be logged in to reply to this topic.