Code: Select all
- Changed: MenuHeight(), StatusBarHeight() and ToolBarHeight() are now deprecated (all returns 0)
On Windows we have AdjustWindowRect/AdjustWindowRectEx() but I don't know what to do for other platforms.
Code: Select all
- Changed: MenuHeight(), StatusBarHeight() and ToolBarHeight() are now deprecated (all returns 0)
I'm trying to figure this out too.Mistrel wrote:What is the cross-platform way to create a window with a menu, toolbar, and status bar, and window decorations, that fits the size of the desktop?Code: Select all
- Changed: MenuHeight(), StatusBarHeight() and ToolBarHeight() are now deprecated (all returns 0)
On Windows we have AdjustWindowRect/AdjustWindowRectEx() but I don't know what to do for other platforms.
Code: Select all
Global __MenuHeight.i = -1
Global __ToolBarHeight.i = -1
Global __StatusBarHeight.i = -1
Procedure __GetBarHeights()
Protected TempWin.i = OpenWindow(#PB_Any, 0, 0, 200, 200, "", #PB_Window_Invisible)
If (TempWin)
Protected BaseHeight.i = WindowHeight(TempWin, #PB_Window_FrameCoordinate)
Protected TempBar.i
TempBar = CreateMenu(#PB_Any, WindowID(TempWin))
If (TempBar)
MenuTitle("")
CompilerIf (#PB_Compiler_Version >= 560)
__MenuHeight = WindowHeight(TempWin, #PB_Window_FrameCoordinate) - BaseHeight
CompilerElse
__MenuHeight = MenuHeight()
CompilerEndIf
FreeMenu(TempBar)
EndIf
TempBar = CreateToolBar(#PB_Any, WindowID(TempWin))
If (TempBar)
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
CompilerIf (#PB_Compiler_Version >= 560)
__ToolbarHeight = WindowHeight(TempWin, #PB_Window_FrameCoordinate) - BaseHeight
CompilerElse
__ToolbarHeight = ToolbarHeight(TempBar)
CompilerEndIf
FreeToolBar(TempBar)
EndIf
TempBar = CreateStatusBar(#PB_Any, WindowID(TempWin))
If (TempBar)
AddStatusBarField(100)
CompilerIf (#PB_Compiler_Version >= 560)
__StatusbarHeight = WindowHeight(TempWin, #PB_Window_FrameCoordinate) - BaseHeight
CompilerElse
__StatusbarHeight = StatusBarHeight(TempBar)
CompilerEndIf
FreeStatusBar(TempBar)
EndIf
CloseWindow(TempWin)
EndIf
EndProcedure
Procedure.i StandardMenuHeight()
If (__MenuHeight = -1)
__GetBarHeights()
EndIf
ProcedureReturn (__MenuHeight)
EndProcedure
Procedure.i StandardToolBarHeight()
If (__ToolbarHeight = -1)
__GetBarHeights()
EndIf
ProcedureReturn (__ToolbarHeight)
EndProcedure
Procedure.i StandardStatusBarHeight()
If (__StatusbarHeight = -1)
__GetBarHeights()
EndIf
ProcedureReturn (__StatusbarHeight)
EndProcedure
Debug StandardMenuHeight()
Debug StandardToolbarHeight()
Debug StandardStatusbarHeight()
Why not simply create a maximized window?Mistrel wrote:What is the cross-platform way to create a window with a menu, toolbar, and status bar, and window decorations, that fits the size of the desktop?
Maybe I want the program to start at the desktop resolution in an unmaximized state? The question is hypothetical.freak wrote:Why not simply create a maximized window?
I'll test it asap.- Changed: ToolBar, Menu and StatusBar are now excluded from inner window area for all OS
Borrow it from the german forum.infratec wrote:
(I always miss a thump up emoticon)
Code: Select all
OpenWindow(0,0,0,600,0,"test")
CreateStatusBar(0,WindowID(0))
statusheight=StatusBarHeight(0)
GetWindowRect_(FindWindow_("Shell_TrayWnd",0),taskwin.RECT)
taskheight=taskwin\bottom-taskwin\top
screenheight=GetSystemMetrics_(#SM_CYSCREEN)
ResizeWindow(0,10,10,600,screenheight-taskheight-(statusheight*2.5))
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Such a workaround is massive overkill to fix the removal of the commands.kenmo wrote:My first idea is: create a dummy window, add a menu, add a toolbar, add a statusbar, and use WindowHeight() Frame vs. Inner to measure the difference.