Changing window flags

Just starting out? Need help? Post your questions and find answers here.
reddon
New User
New User
Posts: 7
Joined: Mon Mar 24, 2014 4:50 pm

Changing window flags

Post by reddon »

Hi all,

Is it possible to change the window's flags? Actually I want to inhibit/disable #PB_Window_SizeGadget and #PB_Window_MaximizeGadget.

Thanks in advance.
User avatar
mk-soft
Always Here
Always Here
Posts: 6210
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Changing window flags

Post by mk-soft »

Windows only

Code: Select all

Procedure Main()
  If OpenWindow(0, 40, 40, 400, 300, "Example", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget)
    
    Protected style, new_style
    
    style = GetWindowLong_(WindowID(0), #GWL_STYLE)
    ;new_style = style & ~#WS_SIZEBOX
    ;new_style = style & ~#WS_MAXIMIZEBOX
    new_style = style & ~#WS_SIZEBOX & ~#WS_MAXIMIZEBOX
    
    SetWindowLong_(WindowID(0), #GWL_STYLE, new_style)
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
    
  EndIf
EndProcedure : Main()
:wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Changing window flags

Post by skywalk »

Try these as you need :wink: Windows only.

Code: Select all

hWnd = WindowID(0)
    ;ON:
    ;SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) | #WS_MINIMIZEBOX)
    ;SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) | #WS_MAXIMIZEBOX)
    ;OFF:
    ;SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) & (#WS_MINIMIZEBOX ! - 1))
    ;SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) & (#WS_MAXIMIZEBOX ! - 1))
    ;SWITCH:
    ;SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) ! #WS_MINIMIZEBOX)
    ;SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) ! #WS_MAXIMIZEBOX)
    ;REDRAW:
    ;SetWindowPos_(hWnd, 0, 0, 0, 0, 0, #SWP_NOZORDER | #SWP_NOMOVE | #SWP_NOSIZE | #SWP_FRAMECHANGED)
    SetWindowLongPtr_(hWnd, #GWL_STYLE, GetWindowLongPtr_(hWnd, #GWL_STYLE) ! #WS_MAXIMIZEBOX)
EDIT: doh!
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
mk-soft
Always Here
Always Here
Posts: 6210
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Changing window flags

Post by mk-soft »

I have to many time 8)

Code: Select all

Procedure DisableSizeWindow(Window, Status)
  
  Protected style
  
  style = GetWindowLongPtr_(WindowID(Window), #GWL_STYLE)
  If Status
    style = style & ~#WS_SIZEBOX & ~#WS_MAXIMIZEBOX & ~#WS_MINIMIZEBOX
  Else
    style = style | #WS_SIZEBOX | #WS_MAXIMIZEBOX | #WS_MINIMIZEBOX
  EndIf
  SetWindowLongPtr_(WindowID(Window), #GWL_STYLE, style)
  
EndProcedure

Procedure Main()
  If OpenWindow(0, 40, 40, 400, 300, "Example", #PB_Window_SystemMenu)
    
    Protected event
    
    ButtonGadget(0, 10, 10, 60, 30, "ON")
    ButtonGadget(1, 80, 10, 60, 30, "OFF")
    
    Repeat
      event = WaitWindowEvent()
      Select event
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 0
              DisableSizeWindow(0, #False)
            Case 1
              DisableSizeWindow(0, #True)
          EndSelect
          
      EndSelect
        
    Until event = #PB_Event_CloseWindow
    
  EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
reddon
New User
New User
Posts: 7
Joined: Mon Mar 24, 2014 4:50 pm

Re: Changing window flags

Post by reddon »

Thank you so much.

I will use WindowBounds(W, WindowWidth(W), WindowHeight(W), WindowWidth(W), WindowHeight(W)) in Mac. I don't have a Mac next to me. But do you think it might work?
Post Reply