[5.60b1] Static control over client area?!

Just starting out? Need help? Post your questions and find answers here.
User avatar
kenmo
Addict
Addict
Posts: 2070
Joined: Tue Dec 23, 2003 3:54 am

Re: [5.60b1] Static control over client area?!

Post by kenmo »

Fred, it is no fun to revert hard work, but thanks for doing it if it prevents unintended side effects!

Thanks for the reminder, normeus :)
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: [5.60b1] Static control over client area?!

Post by chi »

@Fred: Have you tried using WM_NCCALCSIZE to shift menu, toolbar and statusbar? Here is an example that works pretty well :twisted:

(except for the ShowWindow -> Minimize + Maximize part, to trigger WM_NCCALCSIZE in a maximized state... That's kinda ugly)
(also needs extra calculations with AeroSnap enabled which are not implemented yet...)
(and in fullscreen the statusbar is wrongly positioned when its activated before the toolbar)

Code: Select all

Global oldProc, offset

Procedure WndCallback(hWnd, Msg, wParam, lParam)
  Select Msg
    Case #WM_NCCALCSIZE
      Protected ret = DefWindowProc_(hWnd, Msg, wParam, lParam)
      If wParam = 0 : ProcedureReturn 0 : EndIf
      If offset
        Protected *ncc.NCCALCSIZE_PARAMS = lParam
        GetWindowRect_(hWnd, wRect.RECT)
        GetClientRect_(hWnd, cRect.RECT)
        MapWindowPoints_(hWnd, 0, cRect, 2)
        If *ncc\lppos
          *ncc\rgrc[2]\left   = cRect\left
          *ncc\rgrc[2]\top    = cRect\top - offset
          *ncc\rgrc[2]\right  = cRect\right
          *ncc\rgrc[2]\bottom = cRect\bottom
        EndIf
      EndIf
      ProcedureReturn ret
  EndSelect
  ProcedureReturn CallWindowProc_(oldProc, hWnd, Msg, wParam, lParam)
EndProcedure

OpenWindow(0, 0, 0, 800, 500, "demo by chi  : ) ", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
oldProc = SetWindowLongPtr_(WindowID(0), #GWL_WNDPROC, @WndCallback())

ButtonGadget(0, 10, 10, 100, 30, "Toggle Toolbar")
ButtonGadget(1, 110, 10, 100, 30, "Toggle Menu")
ButtonGadget(2, 210, 10, 100, 30, "Toggle Statusbar")
ListViewGadget(3, 10, 50, WindowWidth(0)-20, WindowHeight(0)-60)

HideWindow(0, #False)

Repeat
  event = WaitWindowEvent()
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case 0 ; "Toggle Toolbar"
          
          If IsToolBar(0) = 0
            CreateToolBar(0, WindowID(0))
            ToolBarStandardButton(0, #PB_ToolBarIcon_New)
            ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
            ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
            offset = ToolBarHeight(0)
            If IsZoomed_(WindowID(0)) = 0
              SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + offset, #SWP_NOMOVE|#SWP_NOZORDER)
            Else
              GetWindowPlacement_(WindowID(0), wp.WINDOWPLACEMENT)
              wp\rcNormalPosition\bottom + offset
              SetWindowPlacement_(WindowID(0), wp)
              offset/2
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          Else
            offset = -ToolBarHeight(0)
            FreeToolBar(0)
            If IsZoomed_(WindowID(0)) = 0
              SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + offset, #SWP_NOMOVE|#SWP_NOZORDER)
            Else
              GetWindowPlacement_(WindowID(0), wp.WINDOWPLACEMENT)
              wp\rcNormalPosition\bottom + offset
              SetWindowPlacement_(WindowID(0), wp)
              offset/2
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          EndIf
          offset = 0
          
        Case 1 ; "Toggle Menu"
          
          If IsMenu(0) = 0
            CreateMenu(0, WindowID(0))
            MenuTitle("  File  ")
            If IsZoomed_(WindowID(0)) = 0
              SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + MenuHeight(), #SWP_NOMOVE|#SWP_NOZORDER)
            Else
              GetWindowPlacement_(WindowID(0), wp.WINDOWPLACEMENT)
              wp\rcNormalPosition\bottom + MenuHeight()
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          Else
            If IsZoomed_(WindowID(0)) = 0
              SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - MenuHeight(), #SWP_NOMOVE|#SWP_NOZORDER)
            Else
              GetWindowPlacement_(WindowID(0), wp.WINDOWPLACEMENT)
              wp\rcNormalPosition\bottom - MenuHeight()
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
            FreeMenu(0)
          EndIf
          
        Case 2 ; "Toggle Statusbar"
          
          If IsStatusBar(0) = 0
            CreateStatusBar(0, WindowID(0))
            If IsZoomed_(WindowID(0)) = 0
              SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + StatusBarHeight(0), #SWP_NOMOVE|#SWP_NOZORDER)
            Else
              GetWindowPlacement_(WindowID(0), wp.WINDOWPLACEMENT)
              wp\rcNormalPosition\bottom + StatusBarHeight(0)
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          Else
            If IsZoomed_(WindowID(0)) = 0
              SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - StatusBarHeight(0), #SWP_NOMOVE|#SWP_NOZORDER)
            Else
              GetWindowPlacement_(WindowID(0), wp.WINDOWPLACEMENT)
              wp\rcNormalPosition\bottom - StatusBarHeight(0)
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
            FreeStatusBar(0)
          EndIf
          
      EndSelect
  EndSelect
Until event = #PB_Event_CloseWindow

Et cetera is my worst enemy
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: [5.60b1] Static control over client area?!

Post by chi »

little update:
  • · fixed fullscreen statusbar
    · implemented a quick AeroSnap detection (still buggy)

Code: Select all

Global oldProc, offset

Procedure WndCallback(hWnd, Msg, wParam, lParam)
  Select Msg
    Case #WM_NCCALCSIZE
      Protected ret = DefWindowProc_(hWnd, Msg, wParam, lParam)
      If wParam = 0 : ProcedureReturn 0 : EndIf
      If offset
        Protected *ncc.NCCALCSIZE_PARAMS = lParam
        GetClientRect_(hWnd, cRect.RECT)
        MapWindowPoints_(hWnd, 0, cRect, 2)
        If *ncc\lppos
          *ncc\rgrc[2]\left   = cRect\left
          *ncc\rgrc[2]\top    = cRect\top - offset
          *ncc\rgrc[2]\right  = cRect\right
          *ncc\rgrc[2]\bottom = cRect\bottom
        EndIf
      EndIf
      ProcedureReturn ret
  EndSelect
  ProcedureReturn CallWindowProc_(oldProc, hWnd, Msg, wParam, lParam)
EndProcedure

Procedure IsAeroSnapEnabled()
  deskWidth  = GetSystemMetrics_(0)
  deskHeight = GetSystemMetrics_(1)
  If WindowWidth(0, #PB_Window_FrameCoordinate) = deskWidth/2
    ProcedureReturn #True
  EndIf
  ProcedureReturn #False
EndProcedure

OpenWindow(0, 0, 0, 800, 500, "demo by chi  : ) ", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
oldProc = SetWindowLongPtr_(WindowID(0), #GWL_WNDPROC, @WndCallback())

ButtonGadget(0, 10, 10, 100, 30, "Toggle Toolbar")
ButtonGadget(1, 110, 10, 100, 30, "Toggle Menu")
ButtonGadget(2, 210, 10, 100, 30, "Toggle Statusbar")
ListViewGadget(3, 10, 50, WindowWidth(0)-20, WindowHeight(0)-60)

HideWindow(0, #False)

Repeat
  event = WaitWindowEvent()
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case 0 ; "Toggle Toolbar"
          
          If IsToolBar(0) = 0
            CreateToolBar(0, WindowID(0))
            ToolBarStandardButton(0, #PB_ToolBarIcon_New)
            ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
            ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
            offset = ToolBarHeight(0)
            If IsZoomed_(WindowID(0)) = 0
              If IsAeroSnapEnabled() = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + offset, #SWP_NOMOVE|#SWP_NOZORDER)
              Else
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER)
                offset = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER)
              EndIf
            Else
              wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
              GetWindowPlacement_(WindowID(0), wp)
              wp\rcNormalPosition\bottom + offset
              SetWindowPlacement_(WindowID(0), wp)
              offset/2
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          Else
            offset = -ToolBarHeight(0)
            FreeToolBar(0)
            If IsZoomed_(WindowID(0)) = 0
              If IsAeroSnapEnabled() = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + offset, #SWP_NOMOVE|#SWP_NOZORDER)
              Else
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER)
                offset = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER)
              EndIf
            Else
              wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
              GetWindowPlacement_(WindowID(0), wp)
              wp\rcNormalPosition\bottom + offset
              SetWindowPlacement_(WindowID(0), wp)
              offset/2
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          EndIf
          If IsStatusBar(0) And IsZoomed_(WindowID(0))
            If IsMenu(0)
              menuheight = MenuHeight()
            Else
              menuheight = 0
            EndIf
            SetWindowPos_(StatusBarID(0), #HWND_TOP, 0, WindowHeight(0) - menuheight - StatusBarHeight(0), 0, 0, #SWP_NOSIZE|#SWP_NOZORDER)
          EndIf
          offset = 0
          
        Case 1 ; "Toggle Menu"
          
          If IsMenu(0) = 0
            CreateMenu(0, WindowID(0))
            MenuTitle("  File  ")
            If IsZoomed_(WindowID(0)) = 0
              If IsAeroSnapEnabled() = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + MenuHeight(), #SWP_NOMOVE|#SWP_NOZORDER)
              Else
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER)
                offset = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER)
              EndIf
            Else
              wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
              GetWindowPlacement_(WindowID(0), wp)
              wp\rcNormalPosition\bottom + MenuHeight()
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          Else
            If IsZoomed_(WindowID(0)) = 0
              If IsAeroSnapEnabled() = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - MenuHeight(), #SWP_NOMOVE|#SWP_NOZORDER)
              Else
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER)
                offset = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER)
              EndIf
            Else
              wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
              GetWindowPlacement_(WindowID(0), wp)
              wp\rcNormalPosition\bottom - MenuHeight()
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
            FreeMenu(0)
          EndIf
          
        Case 2 ; "Toggle Statusbar"
          
          If IsStatusBar(0) = 0
            CreateStatusBar(0, WindowID(0))
            If IsZoomed_(WindowID(0)) = 0
              If IsAeroSnapEnabled() = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + StatusBarHeight(0), #SWP_NOMOVE|#SWP_NOZORDER)
              Else
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER)
                offset = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER)
              EndIf
            Else
              wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
              GetWindowPlacement_(WindowID(0), wp)
              wp\rcNormalPosition\bottom + StatusBarHeight(0)
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
          Else
            If IsZoomed_(WindowID(0)) = 0
              If IsAeroSnapEnabled() = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - StatusBarHeight(0), #SWP_NOMOVE|#SWP_NOZORDER)
              Else
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER)
                offset = 0
                SetWindowPos_(WindowID(0), #HWND_TOP, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER)
              EndIf
            Else
              wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
              GetWindowPlacement_(WindowID(0), wp)
              wp\rcNormalPosition\bottom - StatusBarHeight(0)
              SetWindowPlacement_(WindowID(0), wp)
              ShowWindow_(WindowID(0), #SW_SHOWMINIMIZED)
              ShowWindow_(WindowID(0), #SW_SHOWMAXIMIZED)
            EndIf
            FreeStatusBar(0)
          EndIf
          
      EndSelect
  EndSelect
Until event = #PB_Event_CloseWindow

Et cetera is my worst enemy
Fred
Administrator
Administrator
Posts: 18397
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [5.60b1] Static control over client area?!

Post by Fred »

Interesting code, thanks ! May be for next time :).
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: [5.60b1] Static control over client area?!

Post by chi »

... and now it works ;)

Code: Select all

Global oldProc, offset

Procedure WndCallback(hWnd, Msg, wParam, lParam)
  Select Msg
      
    Case #WM_NCCALCSIZE
      Protected ret = DefWindowProc_(hWnd, Msg, wParam, lParam)
      If wParam = 0 : ProcedureReturn 0 : EndIf
      If offset
        Protected *ncc.NCCALCSIZE_PARAMS = lParam
        GetClientRect_(hWnd, cRect.RECT)
        MapWindowPoints_(hWnd, 0, cRect, 2)
        If *ncc\lppos
          *ncc\rgrc[2]\left   = cRect\left
          *ncc\rgrc[2]\top    = cRect\top - offset
          *ncc\rgrc[2]\right  = cRect\right
          *ncc\rgrc[2]\bottom = cRect\bottom
        EndIf
        offset = 0
      EndIf
      ProcedureReturn ret
      
  EndSelect
  ProcedureReturn CallWindowProc_(oldProc, hWnd, Msg, wParam, lParam)
EndProcedure

Procedure AdjustWindowHeight(Window, Height)
  If IsZoomed_(WindowID(Window))
    wp.WINDOWPLACEMENT\Length = SizeOf(WINDOWPLACEMENT)
    GetWindowPlacement_(WindowID(Window), wp)
    wp\rcNormalPosition\bottom + Height
    SetWindowPlacement_(WindowID(Window), wp)
  Else
    ResizeWindow(Window, #PB_Ignore, #PB_Ignore, #PB_Ignore, WindowHeight(Window) + Height)
  EndIf
EndProcedure

OpenWindow(0, 0, 0, 800, 500, "demo by chi  : ) ", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
oldProc = SetWindowLongPtr_(WindowID(0), #GWL_WNDPROC, @WndCallback())

;;; MENU
CreateMenu(0, WindowID(0))
MenuTitle("  File  ")
SetMenu_(WindowID(0), 0)

;;; STATUSBAR
If CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100)
  AddStatusBarField(100)
  AddStatusBarField(#PB_Ignore)
  AddStatusBarField(120)
EndIf
StatusBarText(0, 0, " Status")
StatusBarText(0, 1, "")
StatusBarText(0, 2, "", #PB_StatusBar_Right )
StatusBarText(0, 3, "...", #PB_StatusBar_Center)
StatusBarProgress(0, 1, 0)
ShowWindow_(StatusBarID(0), #SW_HIDE)

;;; TOOLBAR
CreateToolBar(0, WindowID(0))
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
ShowWindow_(ToolBarID(0), #SW_HIDE)
; Important for toolbar to work...
SetWindowLongPtr_(ToolBarID(0),#GWL_STYLE, GetWindowLongPtr_(ToolBarID(0), #GWL_STYLE)|#CCS_NODIVIDER|#CCS_NOPARENTALIGN)
SetWindowPos_(ToolBarID(0), #HWND_TOP, 0, -ToolBarHeight(0), 0, 0, #SWP_NOSIZE|#SWP_NOZORDER|#SWP_NOACTIVATE)

ButtonGadget(0, 10, 10, 100, 30, "Toggle Menu")
ButtonGadget(1, 110, 10, 100, 30, "Toggle Toolbar")
ButtonGadget(2, 210, 10, 100, 30, "Toggle Statusbar")
ListViewGadget(3, 10, 50, WindowWidth(0)-20, WindowHeight(0)-60)

HideWindow(0, #False)

Repeat
  event = WaitWindowEvent()
  Select event
      
    Case #PB_Event_Gadget
      Select EventGadget()
          
          ;;; MENU
        Case 0
          showMenu ! 1
          If showMenu
            AdjustWindowHeight(0, MenuHeight())
            SetMenu_(WindowID(0), MenuID(0))
          Else
            SetMenu_(WindowID(0), 0)
            AdjustWindowHeight(0, -MenuHeight())
          EndIf
          
          ;;; TOOLBAR
        Case 1
          showToolbar = IsWindowVisible_(ToolBarID(0)) ! 1
          If showToolbar
            offset = ToolBarHeight(0)
            AdjustWindowHeight(0, offset)
            LockWindowUpdate_(WindowID(0))
            SetWindowPos_(WindowID(0), 0, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER|#SWP_NOACTIVATE)
            SetWindowPos_(WindowID(0), 0, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER|#SWP_NOACTIVATE)
            LockWindowUpdate_(0)
            ShowWindow_(ToolBarID(0), #SW_SHOW)
          Else
            ShowWindow_(ToolBarID(0), #SW_HIDE)
            offset = -ToolBarHeight(0)
            AdjustWindowHeight(0, offset)
            SetWindowPos_(WindowID(0), 0, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) + 1 , #SWP_NOMOVE|#SWP_NOZORDER|#SWP_NOACTIVATE)
            SetWindowPos_(WindowID(0), 0, 0, 0, WindowWidth(0, #PB_Window_FrameCoordinate), WindowHeight(0, #PB_Window_FrameCoordinate) - 1 , #SWP_NOMOVE|#SWP_NOZORDER|#SWP_NOACTIVATE)
          EndIf
          SetWindowPos_(StatusBarID(0), 0, 0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOZORDER|#SWP_NOACTIVATE)
          
          ;;; STATUSBAR
        Case 2
          showStatusbar ! 1
          If showStatusbar
            AdjustWindowHeight(0, StatusBarHeight(0))
            ShowWindow_(StatusBarID(0), #SW_SHOW)
          Else
            ShowWindow_(StatusBarID(0), #SW_HIDE)
            AdjustWindowHeight(0, -StatusBarHeight(0))
          EndIf
          
      EndSelect
      
  EndSelect
Until event = #PB_Event_CloseWindow

Et cetera is my worst enemy
Post Reply