Page 1 of 1

Wrong OpenWindow Inner Height With ToolBar

Posted: Sun Nov 30, 2025 6:45 pm
by mk-soft
When I was revising FormDesigner, I noticed that there is an error in macOS with OpenWindow and the inner height.
With ToolBar, the inner height is incorrect and deviates from the target height by 14 pixels.
FormDesigner calculates the positions of the gadgets correctly. When the width is changed, the gadgets jump.

P.S.
Thus, the last error with StatuBar was not related to position, but rather to the inner height.

Test-Code

Code: Select all

;-TOP

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(0)
  dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
  ; Resize Gadgets
  ResizeGadget(0, 10, dy - 50, dx - 20, 30)
EndProcedure

Procedure Main()
  Protected dx, dy
  
  #WinStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(0, #PB_Ignore, #PB_Ignore, 600, 400, "Test Window", #WinStyle)
    ; MenuBar
    CreateMenu(0, WindowID(0))
    MenuTitle("&File")
    MenuItem(99, "E&xit")
    
    ; ToolBar
    CreateImage(0, 24, 24, 32, #PB_Image_Transparent)
    If StartDrawing(ImageOutput(0))
      DrawingMode(#PB_2DDrawing_AlphaChannel)
      Box(2, 2, 20, 20, $FF000000 | #Yellow)
      DrawingMode(#PB_2DDrawing_Outlined)
      Box(2, 2, 20, 20, $FF000000 | #Red)
      StopDrawing()
    EndIf
    CreateToolBar(0, WindowID(0))
    ToolBarImageButton(99, ImageID(0))
    
    ; StatusBar
    CreateStatusBar(0, WindowID(0))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(0)
    dy = WindowHeight(0) - StatusBarHeight(0) - MenuHeight()
    StringGadget(0, 10, 350, 580, 30, "Jump Position")
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), 0)
    
    Debug "Window Height (400) = " + WindowHeight(0)
    
    ; Main Loop
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case 0
              Break
          EndSelect
          
        Case #PB_Event_Menu
          Select EventMenu()
            Case 99
              PostEvent(#PB_Event_CloseWindow, 0, 0)
              
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()