Mac Window size keeps changing

  1. 4 days ago

    I was having a problem with the taskbar not showing up in windows. I finally solved it by adding two lines:

    Window1.Fullscreen = False
    Window1.Maximize()

    That worked great for Windows, but it really screwed up the Mac! I have methods that adjust placement of buttons on the screen to keep them centered both horizontally and vertically. However, when I toggle back and forth between several windows the window.height keeps changing. On Window1 it seems to toggle back and forth between 741 and 1000! In other words: I go back and forth between two windows using buttons which call the methods to setup the screen. Each time I come back to Window1 it changes from the last time. How can the window size keep changing? What am I missing?

  2. I found this: " If the window was already maximized when you call this method, then it is restored to its prior state "
    I moved the two statements from the method to the window open event so it doesn't toggle anymore.
    However, the window height is 800 when it first opens, then changes to 922 after it comes back from the other window!

  3. Emile S

    Mar 24 Europe (France, Strasbourg)

    Do you have a ToolBar in that Window ?

  4. I have a Menubar, but I removed the items from it. It is blank.

  5. Okay, I just keep getting more confused.
    I put in a textfield to show the screen.availableheight and the window.height.
    Screen height is 723 and window height is 1222! I thought window height had to be less than the available height.

  6. Norman P

    Mar 24 Pre-Release Testers, Xojo Pro outside drowning sorrows

    why ?
    its certainly possible to have a window that is taller or wider than the screen
    that not always useful or accessible but possible

  7. Emile S

    Mar 24 Europe (France, Strasbourg)
    Edited 4 days ago

    What is a MenuBar ?
    (I asked about a ToolBar and your answer was MenuBar…)
    (Please, look in the docs what is a ToolBar)

  8. Emile, I do not have a Toolbar.
    A MenuBar has the File and Edit menus etc along the top of the screen.

    I had my app working fullscreen, then we decided we should show the taskbar at the bottom so users could switch between programs. I had to turn on the menubar in windows to make the taskbar appear. I also had to use the fullscreen and maximize commands to get it to work.
    It was working perfectly on the Mac, but now everything is screwed up on the Mac, and I don't understand the relationship between screen size, window size etc.
    I want a window with the minimize and close buttons at the top and the taskbar at the bottom.
    The window seems to be bigger than the screen. How do I adjust it?

  9. Beatrix W

    Mar 24 Pre-Release Testers, Third Party Store Europe (Germany)

    First order of business is to understand what you did wrong. Can you isolate the window to make an example?

    What is sometimes a bit tricky is the difference between the full window size and the frame (content? It's too late here) which doesn't include the toolbar. However, when you switch between 741 and 1000 the toolbar or taskbar isn't the culprit.

    Try to make an example or show us your code.

  10. Norman P

    Mar 24 Pre-Release Testers, Xojo Pro outside drowning sorrows

    frame size = windows.bounds

    content = window.top, window.left, window.width, window.height

    they can be very different

  11. Beatrix, How do I share my file?

    Norman, The documentation says how to use a command but it doesn't explain the difference between Screen.width, Window.width, and now windows.bounds?

  12. Norman P

    Mar 24 Pre-Release Testers, Xojo Pro outside drowning sorrows

    screen width is how wide a given screen is in pixels
    no rocket science there

    Window.Width is the size of the CONTENT area of a window - on macOS this is the full width of most windows
    On Windows it is the content area which has a frame around a number of window types
    Height is similar - it related to the content area

    Bounds is the entire size of the window including and outside frames

    So IF you want to make sure a WINDOW has its top left at 0,0 you need to set the BOUNDS
    NOT THE WINDOW.TOP ! as this will put the Content area at 0,0 which can mean the window and its title bar is under the menu bar on macOS
    Lets see if this image helps
    -image-

  13. 3 days ago

    Norman, Thank you! That helped a lot. They need something like that in the documentation!

    It's working perfectly on Windows, But I'm still fighting some ghosts on the Mac.

    For some reason, it only takes effect the 2nd time thru. The first time the window comes up it reports window.bounds.height = 746 and the Top = 0. When I go to another window and back again, then it looks right and the height is 723 and top = 23 which apparently is the height of the menubar. The first time the window opens there is space for the taskbar at the bottom, but it is black. The second time thru it appears normal! The same goes for the second window which uses the same code.

    Also, There is supposed to be a Splashscreen window that comes up first while it is establishing contact with the robot, but that is not showing either.

    Here is the code in a method:
    #If not TargetMacOS then
    Window1.FullScreen = False ' Required to make Taskbar visible!
    #EndIf

    Window1.Maximize()
    Window1.MenuBar = MainMenuBar

    ' Set size of Window
    Var mybounds as New Rect

    mybounds.Left=0
    mybounds.Top = Screen(0).AvailableTop
    mybounds.Height = Screen(0).AvailableHeight
    mybounds.Width = Screen(0).AvailableWidth
    Window1.Bounds = mybounds

    Window1.Show

  14. Norman P

    Mar 25 Pre-Release Testers, Xojo Pro outside drowning sorrows
    Edited 3 days ago

    ah I bet "the first time it comes up " is because you have Window1's implicit instance set to true in the layout designer :)

    when that is true what happens, the FIRST time you use the name "Window1" a new instance is created and it shows up
    that would be in your code on the line

     Window1.Maximize()

    and then you change all the settings and show it again causing it to show a second time

    a way to work around this is

    1. select Window1 and turn IMPLICIT INSTANCE off !!!!!!
    2. also turn Visible OFF for now
    3. set the App.DefaultWindow to "None"
    4. in the app open event put
    dim w as New Window1
    #If not TargetMacOS then
       w.FullScreen = False ' Required to make Taskbar visible!
    #EndIf
    
    w.Maximize()
    w.MenuBar = MainMenuBar
    
    ' Set size of Window
    Var mybounds as New Rect
    
    mybounds.Left=0
    mybounds.Top = Screen(0).AvailableTop
    mybounds.Height = Screen(0).AvailableHeight
    mybounds.Width = Screen(0).AvailableWidth
    w.Bounds = mybounds
    
    w.Show
    

    this will create a new instance, that is initially invisible (because we set visible false in the designer), then set all the sizes, and only once it has done this then it shows this new instance

  15. Emile S

    Mar 25 Europe (France, Strasbourg)
    Edited 3 days ago

    @Emile S Do you have a ToolBar in that Window ?

    Is what I asked some times ago.

    Why ?
    Because I went there, and got that.

    Unfortunately, I totally forgot how I left that bug (probably using Bounds).

    Edit:
    That’s it: I used Norman advice (read above). I found my project.

  16. Thanks Norman, I understand. However, I think it is easier said than done. Window1 has a bunch of Timers, serial, and threads on it, so I have tons of references to Window1. I am wondering if it will be easier to create a second window and use it for my Main Menu screen.

  17. Norman P

    Mar 25 Pre-Release Testers, Xojo Pro outside drowning sorrows

    just a warning that implicit instance will give you grief long term
    it causes all kinds of bugs like the one youre trying to deal with

    lots of old timers will tell you to not do this but ......

or Sign Up to reply!