I had a feature request for BaseElements that to me sound perfectly reasonable : When you’re creating a new window by holding down the option key, can you put it a few pixels below and to the left of the current window in the exact same way the “New Window” command does. Sounds perfectly fine to me, it will be a pain to put into all those scripts, but makes sense and probably should be done.
I had one thought though that makes this a little tricky : What if you’re on windows and have the window maximised. Obviously it shouldn’t do anything at all. You don’t want to lose the maximised state just because you’ve opened a new window. So surely there’s a “Get ( WindowState )” type function that will tell me if the current window is maximised or not. Well it turns out there isn’t.
So how do you tell if a window is maximised? First, this is a windows only function, so check for that. Then check if the window size is as big as can fit on the screen, so compare WindowHeight and WindowWidth to WindowDesktopHeight and WindowDesktopWidth. They should be different only by four pixels, which is the width of a window border. Plus the window should be positioned at the top left of the screen.
But you can easily manually create a window that size and that position, that isn’t maximised. The second trick is to compare the WindowWidth to the WindowContentWidth. This is the size of the FileMaker “desktop” so to speak. And if you have a window that is the same size as the desktop, and positioned on the top left, it slightly expands the WindowContentWidth to show properly. In other words you get the scroll bars on the main FileMaker background. When it’s maximised there is a fixed distance between the two, depending on which LayoutViewState you have ( Form, List or Table view ).
So with all that smarts we can create a CustomFunction called “IsWindowMaximised” that takes no parameters. The function ( for FileMaker 11 ) is :
diff = Case (
Get ( LayoutViewState ) = 0 ; 16 ;
Get ( LayoutViewState ) = 1 ; 19 ;
Get ( LayoutViewState ) = 2 ; 31 ) ;
( Get ( SystemPlatform ) = -2 ) and
( Get ( WindowHeight ) = ( Get ( WindowDesktopHeight ) – 4 ) ) and
( Get ( WindowWidth ) = ( Get ( WindowDesktopWidth ) – 4 ) ) and
( Get ( WindowLeft ) = 0 ) and
( Get ( WindowTop ) = 0 ) and
( ( Get ( WindowWidth ) – diff ) = Get ( WindowContentWidth ) ) )
Be aware though that this version only applies to FileMaker 11, although it should also work fine in 10. In earlier versions the left side status bar will alter what I’ve used as the “diff” variable. With the status bar hidden, the values are similar to the above ( except for Table view which is 19 ), but with the status bar shown, the diff value needs to be 85.
I’ve tested this on XP and Win 7, but not vista although I assume it would be the same as 7.
I hope this is of use to someone else somewhere.
As for when I will build this into BaseElements, well I think it’s a really good suggestion so I will do it. It’s just that there are 1000+ GTRR steps that do the “New Window” option in BaseElements, two for every single link you can click on. One is a normal GTRR and another for GTRR using the found set. So there’s a lot to change 🙂 My kingdom for a completely dynamic GTRR step where I can program the “New Window”, “use Found Set” and “From Table” options, not just the destination layout.
Thanks to Chaim from ProductiveIT for the idea and help with testing.