On Sep 30, 2005, at 3:02 PM, Aparajita Fishman wrote:
Someone suggested to me putting a horizontal splitter on the session monitor between the list of session items and the data area below. However, I cannot get the splitter to resize the form. What is the trick, and does it work with 4D 2003, since there are no pusher splitters?


The splitter doesn't resize the form, it just moves objects on the form.

I use the following code in the script of the splitter to accomplish the window resize (the name of the splitter object is 'prefs_splitter'):

C_LONGINT($left;$top;$right;$bottom)
C_LONGINT($winleft;$wintop;$winright;$winbottom)
C_LONGINT($splitterleft;$splittertop;$splitterright;$splitterbottom)

Case of
: (Form event=On Load ) `lrj 10.21.04 remember where the splitter is initially GET OBJECT RECT(*;"prefs_splitter";prefs_splitter_left;$top; $right;$bottom) `lrj 10.5.04 remember the splitter position so we can restore it

: (Form event=On Clicked ) `lrj 10.21.04 just moved the splitter, find out how far

`determine the coordinates of the accept button and the window GET OBJECT RECT(*;"btn_windows_accept";$left;$top;$right; $bottom)
        GET WINDOW RECT($winleft;$wintop;$winright;$winbottom)

          `where is the splitter
GET OBJECT RECT(*;"prefs_splitter";$splitterleft; $splittertop;$splitterright;$splitterbottom)

        If (($right>$winRight) | ($splitterleft<prefs_splitter_left))
`we just moved the accept button of the right edge of the window OR we moved the splitter to the left
            C_LONGINT($delta)
            $delta:=$splitterleft-prefs_splitter_left

prefs_splitter_left:=$splitterleft `make sure we know where the splitter is now

              `now move the window the same number of pixels
            GET WINDOW RECT($left;$top;$right;$bottom)
            SET WINDOW RECT($left;$top;$right+$delta;$bottom)
        End if

End case

The code boils down to this:
1) when opening the form, use a global var to store where the splitter is (Prefs_Splitter_Left in the above code)

2) when the splitter is moved (Form event=on clicked), I do the following:
    a) get the window position
b) get the new position of the object on the farthest right edge of my form ("btn_windows_accept" is the object name used above). c) If the right edge of that object is beyond the right edge of the window, then the splitter was just used to move it off screen, so I know I have to make the window larger.

I do it by calculating how many pixels the splitter just moved, but you could just as easily do it by adding a pre-defined number of pixels to the right edge of the rightmost object you used above.

This has worked great for a year now. The only thing I never bothered to do was to save the last position of the splitter so that I could move it to that position the next time I opened the form.

HTH,
Randy

----------------------------------------
Randy Jaynes
Management Software


_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to