Page 1 of 1

Add only minimise gadget to window

Posted: Thu Nov 22, 2018 10:43 am
by marcoagpinto
Hello!

I wanted some windows to only have a minimise gadget.

Code: Select all

OpenWindow(#PROPERTIES_WINDOW,MainWindowProperties\x+MainWindowProperties\width-w-5-5-5-4,MainWindowProperties\y+100-16-4,w,h,"Properties",#PB_Window_Tool,WindowID(#WINDOW_MAIN))
I tried:

Code: Select all

#PB_Window_Tool|#PB_Window_MinimizeGadget
But it gets a close gadget instead of a minimise one.

By using only:

Code: Select all

#PB_Window_MinimizeGadget
It gets the minimise gadget but also the close + maximise even if disabled.

How can I do it?

I am using PB 5.70 beta 3.

Thank you!

Re: Add only minimise gadget to window

Posted: Thu Nov 22, 2018 3:41 pm
by salutcava
Hello,
i don't have an answer only a hint. Maybe you can try with the API SetWindowLong / SetWindowLongPtr and the window styles to achieve your goal.

https://docs.microsoft.com/en-us/window ... dow-styles

I hope it will help

Re: Add only minimise gadget to window

Posted: Thu Nov 22, 2018 4:23 pm
by RSBasic
No, it's not possible:

Code: Select all

EnableExplicit

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  
  SetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE, GetWindowLongPtr_(WindowID(0), #GWL_EXSTYLE) | #WS_EX_TOOLWINDOW)
  ;SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0), #GWL_STYLE) | #WS_MINIMIZEBOX)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf

Re: Add only minimise gadget to window

Posted: Thu Nov 22, 2018 6:23 pm
by RSBasic
@marcoagpinto
If you want to have a MinimizeGadget but no CloseGadget:

Code: Select all

EnableMenuItem_(GetSystemMenu_(WindowID(0), #False), #SC_CLOSE, #MF_BYCOMMAND | #MF_DISABLED | #MF_GRAYED)

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 11:37 am
by marcoagpinto
RSBasic wrote:@marcoagpinto
If you want to have a MinimizeGadget but no CloseGadget:

Code: Select all

EnableMenuItem_(GetSystemMenu_(WindowID(0), #False), #SC_CLOSE, #MF_BYCOMMAND | #MF_DISABLED | #MF_GRAYED)
@RSBasic

Hello!

Thank you, but it doesn't work.

Maybe I should place a specific flag in the window command?:

Code: Select all


    ; Open the properties window
    If IsWindow(#PROPERTIES_WINDOW)=#False
      w=200-30-30+4+8
      w+35 ;24/OCT/2014
      h=200-30-30+5+25-10-3+20+2-2
      OpenWindow(#PROPERTIES_WINDOW,MainWindowProperties\x+MainWindowProperties\width-w-5-5-5-4,MainWindowProperties\y+100-16-4,w,h,"Properties",#PB_Window_Tool,WindowID(#WINDOW_MAIN))
;       StickyWindow(#PROPERTIES_WINDOW,#True) ; Removed sticky - 16/OCT/2018
      
      EnableMenuItem_(GetSystemMenu_(WindowID(#PROPERTIES_WINDOW), #False), #SC_CLOSE, #MF_BYCOMMAND | #MF_DISABLED | #MF_GRAYED) ; User RSBasic forum - 22/NOV/2018 6:23pm
      
      ; set the window active
      SetActiveWindow(#PROPERTIES_WINDOW)
      
      ; Place the gadgets
      ImageGadget(#IMAGE_WINDOW_PROPERTIES,4+20+0+20+10+2,0,68,86,0)
      TextGadget(#TEXT_WINDOW_PROPERTIES_1,5+10,100-2-3-3,140+15+100,20,"")
      TextGadget(#TEXT_WINDOW_PROPERTIES_2,5+10,100+20+2-2-3-3-2,140+15+100,20,"")
      TextGadget(#TEXT_WINDOW_PROPERTIES_4,5+10,100+20+2+20+2-2-3-3-2-2,140+15+100,20,"") ; Hi - 5/JAN/2017
      TextGadget(#TEXT_WINDOW_PROPERTIES_3,5+10,100+20+2+20+2+20-2-3-3-2-2,140+15+100,20,"")
      
      ; Place the editor gadget for weapons & gadgets
      EditorGadget(#EDITOR_GADGET_WINDOW_PROPERTIES,-2-2-3-3+5+10,20+5+20+2+100+20+2+20+2-2-3-3-2-2,8+3-40-30-20+140+15+100,3+5+200+200-10-5-3+16+16+5+2,#PB_Editor_ReadOnly)
      
      ; Set the active window back to the main
      SetActiveWindow(#WINDOW_MAIN)
      
    EndIf   
Thank you guys for all the help!

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 12:58 pm
by RSBasic
If you test without #PB_Window_Tool? Then you have minimize button but no Close button. (close button is disabled)

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 1:31 pm
by marcoagpinto
RSBasic wrote:If you test without #PB_Window_Tool? Then you have minimize button but no Close button. (close button is disabled)
@RSBasic

The idea is to have only one gadget in the window, the minimize.

If I have more than one, the window title doesn't fit because the gadgets, even if disabled, take most of the space.

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 1:51 pm
by Dude
marcoagpinto wrote:The idea is to have only one gadget in the window, the minimize.
Windows (the OS) doesn't support that. You'd need to create your own custom window title bar.

An example to get you started: viewtopic.php?f=12&t=44315

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 1:58 pm
by #NULL
If you want it crossplatform maybe a simple borderless window with some gadgets will do it. Looks not too bad with subsystem qt. with gtk3 you will get some trouble with enforced minimum sizes and other layout issues. Also moving the window by dragging the title bar would have to be added. Just an idea :)

Code: Select all

win = OpenWindow(#PB_Any, 50, 100, 800, 600, "..", #PB_Window_ScreenCentered)
AddKeyboardShortcut(win, #PB_Shortcut_Escape, 10)
win2 = OpenWindow(#PB_Any,        50, 100, 100, 200, "..", #PB_Window_WindowCentered | #PB_Window_BorderLess, WindowID(win))
size = 20
win2title = TextGadget(#PB_Any,          0,   0,   100, size, "title", #PB_Text_Border)
win2min   = ButtonGadget(#PB_Any, 100-size,   0,  size, size, "_")
Repeat
  WaitWindowEvent()
Until Event() = #PB_Event_CloseWindow Or Event() = #PB_Event_Menu

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 3:01 pm
by Marc56us
Use a borderLess window and draw your own minimize box

Code: Select all

EnableExplicit

Enumeration 
    #Win
    #Btn_Minimize
    #Btn_Close
EndEnumeration

OpenWindow(#Win, 0, 0, 500, 200, "", #PB_Window_BorderLess | #PB_Window_ScreenCentered)

ButtonGadget(#Btn_Minimize, WindowWidth(#Win) - 30,  10, 20, 20, "_") 
ButtonGadget(#Btn_Close,    WindowWidth(#Win) - 70, 170, 60, 20, "Close") 

Repeat
    Select WaitWindowEvent()
        Case #PB_Event_Gadget
            Select EventGadget()
                Case #Btn_Minimize
                    SetWindowState(#Win, #PB_Window_Minimize)
                Case #Btn_Close
                    Break
            EndSelect
            
        Case #WM_LBUTTONDOWN
            SendMessage_(WindowID(#Win), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)            
    EndSelect
ForEver

End

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 3:12 pm
by RASHAD
Change :

Code: Select all

OpenWindow(#PROPERTIES_WINDOW,MainWindowProperties\x+ MainWindowProperties\width-w-5-5-5-4,MainWindowProperties\y+100-16-4,w,h,"Properties",#PB_Window_Tool, WindowID(#WINDOW_MAIN))
To :

Code: Select all

OpenWindow(#PROPERTIES_WINDOW,MainWindowProperties\x+ MainWindowProperties\width-w-5-5-5-4,MainWindowProperties\y+100-16-4,w,h,"Properties",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget, WindowID(#WINDOW_MAIN))

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 3:54 pm
by marcoagpinto
@RASHAD:

Thank you and all the users for the help.

However:
Image

It does show the minimise gadget, but like I commented above, it also shows the other ones, hiding the window title :cry:

Re: Add only minimise gadget to window

Posted: Fri Nov 23, 2018 4:04 pm
by RSBasic
It is not possible to create only the minimize button. You can create your own title bar. See here: viewtopic.php?p=529258#p529258