13 Replies Latest reply on May 5, 2016 2:29 PM by tcmeyers

    Method to obtain layout Part sizes for smart window resizing

    tcmeyers

      I'd like to write a script to resize the height of a list window based on the number of records in the found set. In this application it will typically start with just one record, but as the user adds or deletes/omits records (by script) I want the window to get vertically longer/shorter so that it's always just the right size to show the header, body (X number of records worth) and footer without the user scrolling.

       

      I haven't found a function to return the values of the Header height, Body height, and Footer height. I can manually provide these, but my script then needs to be manually updated any time the size of any of these change. I really want to avoid that. In fact I'd like the script to work in any similar situation, not just this one layout.

       

      Am I missing the function? I didn't find it in Design functions, and unfortunately GetObjectAttributes won't work for me because I'm not allowed to assign object names to the Parts.

       

      Ideas, please?

       

      Troy

        • 1. Re: Method to obtain layout Part sizes for smart window resizing
          rgordon

          These are all fixed values. They only can be changed in layout mode. If you want to now how big the window should be in list view, multiple the number of records by the body height and add the header and footer height. 

          • 2. Re: Method to obtain layout Part sizes for smart window resizing
            RickWhitelaw

            I would size the window to as tall as convenient and the scroll bar or up/down arrows will take care of the rest. The question is why you would want to shrink the window in the first place.

            • 3. Re: Method to obtain layout Part sizes for smart window resizing
              tcmeyers

              rgordon,

               

              Thank you for the reply. Yes, this is the method we have been using. I'm now wanting to avoid needing to rewrite the script for each different layout, or layout modification.

               

              Troy

              • 4. Re: Method to obtain layout Part sizes for smart window resizing
                tcmeyers

                Rick,

                 

                Thank you for your reply.

                 

                Defaulting the window to a large-enough-for-all-cases length is just not as user-friendly as I'd like. Some of the controls are in the footer, so I'd like the footer always as close to the top as possible. No, I don't want those in the header. Attached is a video example of one of the spots we use the (manually-written) method, so you can see WHY it's wanted.

                 

                Troy

                • 5. Re: Method to obtain layout Part sizes for smart window resizing
                  rgordon

                  Fortunately you are doing this on a Mac.  Don't think it would work as nice on a PC.  Here is an idea.  Draw a transparent vertical line in each part that is the same size as the part.  Then assign an object name  to each line.  Use getlayoutobjectattritute to find the height of each object.  Do this for each layout and use the same object names.  This should allow you to write one fairly easy script to accomplish what you want.

                  • 6. Re: Method to obtain layout Part sizes for smart window resizing
                    rgordon

                    Here is another idea.  Use a trailing grand summary part instead of a footer. The grand summary will come up to the bottom of the body   Then you can keep the size of your window consistent.

                    • 7. Re: Method to obtain layout Part sizes for smart window resizing
                      user19752

                      I agree you, can't get why need to shrink.

                       

                      Troy, for a record, use form view then "Adjust Window [ resize to fit ]" make the size to you want.

                      For more records with list view, you will need to scroll after user add some records.

                      • 8. Re: Method to obtain layout Part sizes for smart window resizing
                        tcmeyers

                        rgordon,

                         

                        In some places I'm actually already using a trailing grand summary for other reasons. But still I don't want an extra-large window. I dunno, the size-changing window seems much cleaner to me.

                         

                        I used your idea of transparent lines, but I know I would forget to alter them any time I altered the layout, and that's the purpose of the script, not having to remember to change values all over the place when I do a layout edit. So, instead I made them obvious, hard-to-ignore measuring stick, off to the right in the invisible layout area. Functions like:

                        GetLayoutObjectAttribute ( "BodyHeight" ;  "height" )

                        are indeed providing the info I wanted.

                         

                        I've attached a screenshot of the measuring stick, in case I'm being unclear.

                         

                        Thanks!

                         

                        Troy

                        • 9. Re: Method to obtain layout Part sizes for smart window resizing
                          tcmeyers

                          user19752,

                           

                          Thank you for the reply. I don't want to do it the "normal" way, however. Perhaps if you look at the video I attached to my reply to Rick, you'll see some validation for what I'm doing.

                           

                          Troy

                          • 10. Re: Method to obtain layout Part sizes for smart window resizing
                            rgordon

                            if you want to make it simpler all you really need are horizontal lines at the start of the body and the end of the body. With these two measurements you should be able to figure out everything you need.

                            • 11. Re: Method to obtain layout Part sizes for smart window resizing
                              rgordon

                              I initially wondered why you wanted to do what you were doing. Made since after watching your video.

                               

                              Roy Gordon

                              PSFE

                              Sent from my iPhone

                              • 12. Re: Method to obtain layout Part sizes for smart window resizing
                                tcmeyers

                                rgordon,

                                 

                                Good idea, I think.

                                 

                                However my earlier "measuring stick" method does NOT work in actual application, some of the GetLayoutObjectAttribute calls apparently only work when in Layout mode. They return null when in browse mode, much to my surprise, even when I moved the measuring sticks onto the visible area of the layout.

                                 

                                The exception is the Trailing Grand Summary Height one, of all things. It works in Layout and Browse, and whether it's in the visible or invisible part of the layout.

                                 

                                There must be a cause for this, since one works, I'll fiddle around.

                                 

                                I'll also try the above/below body line method. Indeed, it's doubtful I'd forget those when I'm editing a layout. For those of course the attribute requested would be "top"....

                                 

                                I'm trying this as I type, and interestingly the line method also returned NULL in Browse mode, but when I moved the upper line up one pixel, ALL of the functions now return correct values in Browse mode. A bit flaky, but I can work with that.

                                 

                                I think I just discovered the solution to the NULL problem, all these functions, including the new AboveBodyLine and BodyBottomLine only return values when it is the FIRST record that is active. For any other record, only the TrailingGrandSummaryHeight and BodyBottomLine return values, and the BodyBottomLine value changes based on how far down that record is from the top of the window (in other words, staying on the same record, but scrolling, if available, changes the value).

                                 

                                I also tried TrailingGrandSummaryBottomLine and that actually only returns a value if the LAST record is active.

                                 

                                Between all these things, I expect I can find a good solution.

                                 

                                Troy

                                • 13. Re: Method to obtain layout Part sizes for smart window resizing
                                  tcmeyers

                                  I have a working solution, and had to do some unexpected things. It needs only ONE named object at the bottom of the Trailing Grand Summary. I used a visible line, so that I'll remember to move it if I alter the TGS. This method takes care of Body part size changes, etc. even though there is just the one named object. Perhaps the script and comments will be self-explanitory.

                                   

                                  Resize Variable Height Window based on BottomLine object, distance passed in (any layout with that obj)

                                   

                                  #Layout must have a line at the bottom of the Trailing Grand Summary, pass in as a List the object name (i.e. "BottomLine")... #...and the desired distance from the top of it to the bottom of the window (i.e. 18 pt)
                                  Set Variable [ $bottomObjectName; Value:GetValue ( Get ( ScriptParameter ) ; 1 ) ]

                                   

                                  #The next is the height of the bottom bar of the Filemaker window, where sometimes zoom level, etc. shows #If the Bottom Object is not quite at the bottom, this needs to be slightly larger. 18 probably works for all.

                                  Set Variable [ $distanceToWindowBottom; Value:GetValue ( Get ( ScriptParameter ) ; 2 ) ]

                                   

                                  #If none supplied, use some defaults:

                                  If [ $bottomObjectName = "" ]
                                   
                                  Set Variable [ $bottomObjectName; Value:"BottomLine" ]

                                    Set Variable [ $distanceToWindowBottom; Value:18 ]

                                  End If


                                  Freeze Window

                                  #Remember current record number, because some record selection and scrolling must occur to get a good

                                  TrailingGrandSummaryBottomLine location

                                  Set Variable [ $currentRecordNumber; Value:Get ( RecordNumber ) ]

                                   

                                  #These 3 moves are necessary to get a good location value

                                  Go to Record/Request/Page [ Last ]

                                  Scroll Window [ End ]

                                  Scroll Window [ Home ]

                                   

                                  #GetLayoutObjectAttribute should now work, but note that only "top" does reliably, not "bottom"

                                  Set Variable [ $bottomObjectsBottomDistanceFromScreenTop; Value:GetLayoutObjectAttribute ( $bottomObjectName ; "top" ) ]

                                   

                                  #$bottomObjectsBottomDistanceFromScreenTop is the distance from the bottom of the Mac's MENU BAR to it, not just inside the

                                  window

                                   

                                  #Calculate and set new window size

                                  Set Variable [ $wantedWindowHeight; Value:$bottomObjectsBottomDistanceFromScreenTop - Get ( WindowTop ) + $distanceToWindowBottom ]

                                  Move/Resize Window [ Current Window; Height: $wantedWindowHeight ]

                                   

                                  #Return focus to originally selected record

                                  Go to Record/Request/Page [ $currentRecordNumber ] [ No dialog ]

                                   

                                  ---Troy